qp.decomposition.all_decomps¶
- all_decomps(op, skip_ops=None)[source]¶
Collect all decomposition rules downstream of an Operator.
- Parameters:
- Returns:
A map from abstract operators to their applicable rules
- Return type:
dict[Operator2, list[DecompositionRule]]
>>> from pennylane.typing import Wire, Float
>>> rules_map = all_decomps(qp.X(0)) >>> len(rules_map) 66 >>> rules_map[qp.RX(Float, Wire[1])] [DecompositionRule(name=_rx_to_rot), DecompositionRule(name=_rx_to_rz_ry), DecompositionRule(name=_rx_to_ppr), DecompositionRule(name=_rx_to_ry_cliff), DecompositionRule(name=_rx_to_rz_cliff)]
The keys from a rule map can be reused on successive calls to avoid recollecting the same nodes. Note that if an op is skipped, it’s children will also not be added.
>>> qp.decomposition.all_decomps(qp.Y(0), skip_ops=rules_map) {}