MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / init_qalloc

Method init_qalloc

python/cudaq/kernel/kernel_builder.py:746–758  ·  view source on GitHub ↗

Generate pattern to convert `initializer` to a `state` object.

(self, statePtr, wasCreated)

Source from the content-addressed store, hash-verified

744 return str(self.module)
745
746 def init_qalloc(self, statePtr, wasCreated):
747 """
748 Generate pattern to convert `initializer` to a `state` object.
749 """
750 with self.ctx, self.insertPoint, self.loc:
751 i64Ty = self.getIntegerType()
752 veqTy = quake.VeqType.get()
753 numQubits = quake.GetNumberOfQubitsOp(i64Ty, statePtr).result
754 qubits = quake.AllocaOp(veqTy, size=numQubits).result
755 ini = quake.InitializeStateOp(veqTy, qubits, statePtr).result
756 if wasCreated:
757 quake.DeleteStateOp(statePtr)
758 return ini
759
760 def get_state_ref(self, stateWrapper):
761 with self.ctx, self.insertPoint, self.loc:

Callers 1

qallocMethod · 0.95

Calls 2

getIntegerTypeMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected