This is a utility function that applies a general quantum operation to the internal PyKernel MLIR ModuleOp.
(self,
opName,
parameters,
controls,
target,
isAdj=False,
context=None)
| 45 | |
| 46 | |
| 47 | def __generalOperation(self, |
| 48 | opName, |
| 49 | parameters, |
| 50 | controls, |
| 51 | target, |
| 52 | isAdj=False, |
| 53 | context=None): |
| 54 | """ |
| 55 | This is a utility function that applies a general quantum operation to the |
| 56 | internal PyKernel MLIR ModuleOp. |
| 57 | """ |
| 58 | opCtor = getattr(quake, '{}Op'.format(opName.title())) |
| 59 | self.clearCache() |
| 60 | |
| 61 | if quake.RefType.isinstance(target.mlirValue.type): |
| 62 | opCtor([], parameters, controls, [target.mlirValue], is_adj=isAdj) |
| 63 | return |
| 64 | |
| 65 | # Must be a `veq`, get the size |
| 66 | size = quake.VeqSizeOp(self.getIntegerType(), target.mlirValue) |
| 67 | |
| 68 | def body(idx): |
| 69 | extracted = quake.ExtractRefOp(quake.RefType.get(context), |
| 70 | target.mlirValue, |
| 71 | -1, |
| 72 | index=idx).result |
| 73 | opCtor([], parameters, controls, [extracted], is_adj=isAdj) |
| 74 | |
| 75 | self.createInvariantForLoop(size, body) |
| 76 | |
| 77 | |
| 78 | def get_parameter_value(self, parameter): |
no test coverage detected