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

Method __measure

python/cudaq/kernel/kernel_builder.py:1128–1142  ·  view source on GitHub ↗

Common implementation for `mz` / `mx` / `my`. Emits the measurement op of class `opClass` against `target`, optionally tagging the result with `regName`, and returns the result as a :class:`QuakeValue`.

(self, opClass, target, regName)

Source from the content-addressed store, hash-verified

1126 )
1127
1128 def __measure(self, opClass, target, regName):
1129 """Common implementation for `mz` / `mx` / `my`. Emits the measurement
1130 op of class `opClass` against `target`, optionally tagging the result
1131 with `regName`, and returns the result as a :class:`QuakeValue`."""
1132 with self.ctx, self.insertPoint, self.loc:
1133 measTy = cc.MeasureHandleType.get()
1134 if quake.VeqType.isinstance(target.mlirValue.type):
1135 measTy = cc.StdvecType.get(measTy)
1136 if regName is not None:
1137 res = opClass(measTy, [], [target.mlirValue],
1138 registerName=StringAttr.get(regName,
1139 context=self.ctx))
1140 else:
1141 res = opClass(measTy, [], [target.mlirValue])
1142 return self.__createQuakeValue(res.measOut)
1143
1144 def mz(self, target, regName=None):
1145 """

Callers 3

mzMethod · 0.95
mxMethod · 0.95
myMethod · 0.95

Calls 2

__createQuakeValueMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected