qml.resource.add_in_series¶
- add_in_series(r1, r2)[source]¶
Add two
Resources
objects assuming the circuits are executed in series.The gates in
r1
andr2
are assumed to act on the same qubits. The resulting circuit depth is the sum of the depths ofr1
andr2
. To add resources as if they were executed in parallel seeadd_in_parallel()
.- Parameters
- Returns
the combined resources
- Return type
Usage Details
Example
First we build two
Resources
objects.from pennylane.measurements import Shots from pennylane.resource import Resources r1 = Resources( num_wires = 2, num_gates = 2, gate_types = {"Hadamard": 1, "CNOT": 1}, gate_sizes = {1: 1, 2: 1}, depth = 2, shots = Shots(10) ) r2 = Resources( num_wires = 3, num_gates = 2, gate_types = {"RX": 1, "CNOT": 1}, gate_sizes = {1: 1, 2: 1}, depth = 1, shots = Shots((5, (2, 10))) )
Now we print their sum.
>>> print(qml.resource.add_in_series(r1, r2)) wires: 3 gates: 4 depth: 3 shots: Shots(total=35, vector=[10 shots, 5 shots, 2 shots x 10]) gate_types: {'Hadamard': 1, 'CNOT': 2, 'RX': 1} gate_sizes: {1: 2, 2: 2}
code/api/pennylane.resource.add_in_series
Download Python script
Download Notebook
View on GitHub