qml.resource.add_in_parallel¶
- add_in_parallel(r1, r2)[source]¶
Add two
Resources
objects assuming the circuits are executed in parallel.The gates in
r2
andr2
are assumed to act on disjoint sets of qubits. The resulting circuit depth is the max depth ofr1
andr2
. To add resources as if they were executed in series seeadd_in_series()
.- 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_parallel(r1, r2)) wires: 5 gates: 4 depth: 2 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_parallel
Download Python script
Download Notebook
View on GitHub