Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 2608, missed pointer load on captured variable #2616

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions python/cudaq/kernel/ast_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,7 @@ def bodyBuilder(iterVar):
qubitTargets = [self.popValue() for _ in range(numValues - 1)]
qubitTargets.reverse()
param = self.popValue()
param = self.ifPointerThenLoad(param)
if IntegerType.isinstance(param.type):
param = arith.SIToFPOp(self.getFloatType(), param).result
elif not F64Type.isinstance(param.type):
Expand All @@ -1681,6 +1682,7 @@ def bodyBuilder(iterVar):
control = self.popValue()
self.checkControlAndTargetTypes([control], [target])
param = self.popValue()
param = self.ifPointerThenLoad(param)
if IntegerType.isinstance(param.type):
param = arith.SIToFPOp(self.getFloatType(), param).result
elif not F64Type.isinstance(param.type):
Expand Down Expand Up @@ -1807,6 +1809,8 @@ def bodyBuilder(iterVal):
self.checkControlAndTargetTypes([], qubitTargets)
params = all_args[-3:]
params.reverse()
for i, p in enumerate(params):
params[i] = self.ifPointerThenLoad(p)
for idx, val in enumerate(params):
if IntegerType.isinstance(val.type):
params[idx] = arith.SIToFPOp(self.getFloatType(),
Expand Down Expand Up @@ -1914,6 +1918,7 @@ def bodyBuilder(iterVal):
qubits = self.popValue()
self.checkControlAndTargetTypes([], [qubits])
theta = self.popValue()
theta = self.ifPointerThenLoad(theta)
if IntegerType.isinstance(theta.type):
theta = arith.SIToFPOp(self.getFloatType(), theta).result
quake.ExpPauliOp(theta, qubits, pauli=pauliWord)
Expand Down
Loading