qml.estimator.resource_operator.CompressedResourceOp¶
- class CompressedResourceOp(op_type, num_wires, params=None, name=None)[source]¶
Bases:
objectDefines a lightweight class corresponding to the operator type and its parameters.
This class is a minimal representation of a
ResourceOperator, containing only the operator type and the necessary parameters to estimate its resources. It is designed for efficient hashing and comparison, allowing it to be used effectively in collections where uniqueness and quick lookups are important.- Parameters:
op_type (type[ResourceOperator]) – the class object of an operation which inherits from
ResourceOperatornum_wires (int) – The number of wires that the operation acts upon, excluding any auxiliary wires that are allocated on decomposition.
params (dict) – A dictionary containing the minimal pairs of parameter names and values required to compute the resources for the given operator.
name (str | None) – A custom name for the compressed operator. If not provided, a name will be generated using
op_type.make_tracking_namewith the given parameters.
Usage Details
This representation is the minimal amount of information required to estimate resources for an operator.
Example
>>> from pennylane import estimator as qre >>> compressed_hadamard = qre.CompressedResourceOp(qre.Hadamard, num_wires=1) >>> print(compressed_hadamard) CompressedResourceOp(Hadamard, num_wires=1)
Attributes