qml.resource.Resources¶
- class Resources(num_wires=0, num_gates=0, gate_types=<factory>, gate_sizes=<factory>, depth=0, shots=<factory>)[source]¶
Bases:
object
Contains attributes which store key resources such as number of gates, number of wires, shots, depth and gate types.
- Parameters
num_wires (int) – number of qubits
num_gates (int) – number of gates
gate_types (dict) – dictionary storing operation names (str) as keys and the number of times they are used in the circuit (int) as values
gate_sizes (dict) – dictionary storing the number of \(n\) qubit gates in the circuit as a key-value pair where \(n\) is the key and the number of occurances is the value
depth (int) – the depth of the circuit defined as the maximum number of non-parallel operations
shots (Shots) – number of samples to generate
Usage Details
The resources being tracked can be accessed as class attributes. Additionally, the
Resources
instance can be nicely displayed in the console.Example
>>> r = Resources(num_wires=2, num_gates=2, gate_types={'Hadamard': 1, 'CNOT':1}, gate_sizes={1: 1, 2: 1}, depth=2) >>> print(r) wires: 2 gates: 2 depth: 2 shots: Shots(total=None) gate_types: {'Hadamard': 1, 'CNOT': 1} gate_sizes: {1: 1, 2: 1}
Attributes