Skip to content

Commit

Permalink
Fix a bug in the implementation of constantSize().
Browse files Browse the repository at this point in the history
Workaround a bad test. This test was never testing the c_if calls
apparently.

Signed-off-by: Eric Schweitz <[email protected]>
  • Loading branch information
schweitzpgi committed Dec 13, 2024
1 parent 08509fa commit f12314f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion runtime/cudaq/builder/QuakeValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ QuakeValue QuakeValue::size() {

std::optional<std::size_t> QuakeValue::constantSize() {
if (auto qvecTy = dyn_cast<quake::VeqType>(getValue().getType()))
return qvecTy.getSize();
if (qvecTy.hasSpecifiedSize())
return qvecTy.getSize();

return std::nullopt;
}
Expand Down
5 changes: 4 additions & 1 deletion unittests/Optimizer/QuakeSynthTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ TEST(QuakeSynthTests, checkVectorOfInt) {
kernel.h(aq);
kernel.z(aq);
kernel.h(q);
for (std::size_t i = 0; i < *q.constantSize(); ++i) {
// FIXME: This test never really tested the c_if in this loop. The call to
// constantSize just returned 0.
std::size_t unrollBy = q.constantSize().has_value() ? *q.constantSize() : 0;
for (std::size_t i = 0; i < unrollBy; ++i) {
kernel.c_if(hiddenBits[i], [&]() { kernel.x<cudaq::ctrl>(aq, q[i]); });
}
kernel.h(q);
Expand Down

0 comments on commit f12314f

Please sign in to comment.