Removed duplicated self.options
This commit is contained in:
@@ -7,22 +7,32 @@ from qibotn.MPSUtils import get_initial_mps, apply_gate
|
|||||||
|
|
||||||
|
|
||||||
class QiboCircuitToMPS:
|
class QiboCircuitToMPS:
|
||||||
def __init__(self, circ_qibo, gate_algo, dtype='complex128', rand_seed=0,):
|
def __init__(
|
||||||
|
self,
|
||||||
|
circ_qibo,
|
||||||
|
gate_algo,
|
||||||
|
dtype="complex128",
|
||||||
|
rand_seed=0,
|
||||||
|
):
|
||||||
np.random.seed(rand_seed)
|
np.random.seed(rand_seed)
|
||||||
cp.random.seed(rand_seed)
|
cp.random.seed(rand_seed)
|
||||||
|
|
||||||
self.num_qubits = circ_qibo.nqubits
|
self.num_qubits = circ_qibo.nqubits
|
||||||
self.handle = cutn.create()
|
self.handle = cutn.create()
|
||||||
self.options = {'handle': self.handle}
|
|
||||||
self.dtype = dtype
|
self.dtype = dtype
|
||||||
self.mps_tensors = get_initial_mps(self.num_qubits, dtype=dtype)
|
self.mps_tensors = get_initial_mps(self.num_qubits, dtype=dtype)
|
||||||
circuitconvertor = QiboCircuitToEinsum(circ_qibo)
|
circuitconvertor = QiboCircuitToEinsum(circ_qibo)
|
||||||
|
|
||||||
for (gate, qubits) in circuitconvertor.gate_tensors:
|
for gate, qubits in circuitconvertor.gate_tensors:
|
||||||
# mapping from qubits to qubit indices
|
# mapping from qubits to qubit indices
|
||||||
# apply the gate in-place
|
# apply the gate in-place
|
||||||
apply_gate(self.mps_tensors, gate, qubits,
|
apply_gate(
|
||||||
algorithm=gate_algo, options=self.options)
|
self.mps_tensors,
|
||||||
|
gate,
|
||||||
|
qubits,
|
||||||
|
algorithm=gate_algo,
|
||||||
|
options={"handle": self.handle},
|
||||||
|
)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
cutn.destroy(self.handle)
|
cutn.destroy(self.handle)
|
||||||
|
|||||||
Reference in New Issue
Block a user