qp.testing.find_eqns¶
- find_eqns(jaxpr, primitive)[source]¶
Find the equations in a jaxpr that use a given primitive.
Only the top-level equations are searched, not those of jaxprs nested inside higher-order primitives.
- Parameters:
jaxpr (jax.extend.core.Jaxpr | jax.extend.core.ClosedJaxpr) – the jaxpr to search
primitive (jax.extend.core.Primitive) – the primitive to look for
- Returns:
the matching equations, in program order
- Return type:
list[jax.extend.core.JaxprEqn]
Example
Unpacking the result checks that there is exactly one matching equation:
>>> from pennylane.capture.primitives import operator_p >>> qp.capture.enable() >>> plxpr = jax.make_jaxpr(lambda x: qp.RX(x, 0))(0.5) >>> [eqn] = qp.testing.find_eqns(plxpr, operator_p) >>> eqn.params["op_cls"] <class 'pennylane.ops.qubit.parametric_ops_single_qubit.RX'>