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

[Tests] [Python] Updates to 'pycudaq-mlir' tests #1405

Merged
merged 13 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
25 changes: 14 additions & 11 deletions python/tests/mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,26 @@ set(PYCUDAQMLIR_TEST_PARAMS
pycudaqmlir_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)

set(PYCUDAQMLIR_TEST_DEPENDS
_pycudaq _quakeDialect
CUDAQuantumPythonModules
FileCheck)

add_custom_target(pycudaq-mlir-test-depends DEPENDS ${PYCUDAQ_TEST_DEPENDS})
add_custom_target(pycudaqmlir-test-depends DEPENDS ${PYCUDAQMLIR_TEST_DEPENDS})
# set_target_properties(pycudaqmlir-test-depends PROPERTIES FOLDER "Tools")
# set_target_properties(pycudaqmlir-test-depends PROPERTIES FOLDER "Tests")

add_lit_testsuite(check-py-cudaq-mlir "Running cudaq python regression tests."
add_lit_testsuite(check-pycudaq-mlir "Running cudaq python regression tests."
${CMAKE_CURRENT_BINARY_DIR}
PARAMS ${PYCUDAQ_TEST_PARAMS}
DEPENDS ${PYCUDAQ_TEST_DEPENDS}
PARAMS ${PYCUDAQMLIR_TEST_PARAMS}
DEPENDS ${PYCUDAQMLIR_TEST_DEPENDS}
)
set_target_properties(check-py-cudaq-mlir PROPERTIES FOLDER "Tools")
set_target_properties(check-pycudaq-mlir PROPERTIES FOLDER "Tests")
set_target_properties(check-pycudaq-mlir PROPERTIES FOLDER "Tools")

add_lit_testsuites(PYCUDAQMLIR ${CMAKE_CURRENT_SOURCE_DIR}
PARAMS ${NVQPP_TEST_PARAMS}
DEPENDS ${NVQPP_TEST_DEPENDS})
PARAMS ${PYCUDAQMLIR_TEST_PARAMS}
DEPENDS ${PYCUDAQMLIR_TEST_DEPENDS})

# Add nvqpp tests to the ctest suite
add_test(NAME py-cudaq-tests-mlir
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target check-py-cudaq-mlir
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME pycudaq-mlir
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target check-pycudaq-mlir
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
73 changes: 39 additions & 34 deletions python/tests/mlir/ast_break.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,53 +34,58 @@ def kernel(x: float):
# CHECK-LABEL: func.func @__nvqpp__mlirgen__kernel(
# CHECK-SAME: %[[VAL_0:.*]]: f64) attributes {"cudaq-entrypoint"} {
# CHECK: %[[VAL_1:.*]] = arith.constant 5.000000e+00 : f64
# CHECK: %[[VAL_2:.*]] = arith.constant 10 : i64
# CHECK: %[[VAL_3:.*]] = arith.constant 2 : i64
# CHECK: %[[VAL_4:.*]] = arith.constant 1 : i64
# CHECK: %[[VAL_2:.*]] = arith.constant 1 : i64
# CHECK: %[[VAL_3:.*]] = arith.constant 10 : i64
khalatepradnya marked this conversation as resolved.
Show resolved Hide resolved
# CHECK: %[[VAL_4:.*]] = arith.constant 2 : i64
# CHECK: %[[VAL_5:.*]] = arith.constant 0 : i64
# CHECK: %[[VAL_6:.*]] = arith.constant 4 : i64
# CHECK: %[[VAL_7:.*]] = cc.alloca f64
# CHECK: cc.store %[[VAL_0]], %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_8:.*]] = quake.alloca !quake.veq<4>
# CHECK: %[[VAL_9:.*]] = cc.alloca !cc.array<i64 x 10>
# CHECK: %[[VAL_10:.*]] = cc.loop while ((%[[VAL_11:.*]] = %[[VAL_5]]) -> (i64)) {
# CHECK: %[[VAL_12:.*]] = arith.cmpi slt, %[[VAL_11]], %[[VAL_2]] : i64
# CHECK: cc.condition %[[VAL_12]](%[[VAL_11]] : i64)
# CHECK: %[[VAL_10:.*]] = cc.alloca i64
# CHECK: cc.store %[[VAL_5]], %[[VAL_10]] : !cc.ptr<i64>
# CHECK: %[[VAL_11:.*]] = cc.loop while ((%[[VAL_12:.*]] = %[[VAL_5]]) -> (i64)) {
# CHECK: %[[VAL_13:.*]] = arith.cmpi slt, %[[VAL_12]], %[[VAL_3]] : i64
# CHECK: cc.condition %[[VAL_13]](%[[VAL_12]] : i64)
# CHECK: } do {
# CHECK: ^bb0(%[[VAL_13:.*]]: i64):
# CHECK: %[[VAL_14:.*]] = cc.compute_ptr %[[VAL_9]]{{\[}}%[[VAL_13]]] : (!cc.ptr<!cc.array<i64 x 10>>, i64) -> !cc.ptr<i64>
# CHECK: cc.store %[[VAL_13]], %[[VAL_14]] : !cc.ptr<i64>
# CHECK: cc.continue %[[VAL_13]] : i64
# CHECK: ^bb0(%[[VAL_14:.*]]: i64):
# CHECK: %[[VAL_15:.*]] = cc.load %[[VAL_10]] : !cc.ptr<i64>
# CHECK: %[[VAL_16:.*]] = cc.compute_ptr %[[VAL_9]]{{\[}}%[[VAL_15]]] : (!cc.ptr<!cc.array<i64 x 10>>, i64) -> !cc.ptr<i64>
# CHECK: cc.store %[[VAL_15]], %[[VAL_16]] : !cc.ptr<i64>
# CHECK: %[[VAL_17:.*]] = arith.addi %[[VAL_15]], %[[VAL_2]] : i64
# CHECK: cc.store %[[VAL_17]], %[[VAL_10]] : !cc.ptr<i64>
# CHECK: cc.continue %[[VAL_14]] : i64
# CHECK: } step {
# CHECK: ^bb0(%[[VAL_15:.*]]: i64):
# CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_15]], %[[VAL_4]] : i64
# CHECK: cc.continue %[[VAL_16]] : i64
# CHECK: ^bb0(%[[VAL_18:.*]]: i64):
# CHECK: %[[VAL_19:.*]] = arith.addi %[[VAL_18]], %[[VAL_2]] : i64
# CHECK: cc.continue %[[VAL_19]] : i64
# CHECK: } {invariant}
# CHECK: %[[VAL_17:.*]] = cc.loop while ((%[[VAL_18:.*]] = %[[VAL_5]]) -> (i64)) {
# CHECK: %[[VAL_19:.*]] = arith.cmpi slt, %[[VAL_18]], %[[VAL_2]] : i64
# CHECK: cc.condition %[[VAL_19]](%[[VAL_18]] : i64)
# CHECK: %[[VAL_20:.*]] = cc.loop while ((%[[VAL_21:.*]] = %[[VAL_5]]) -> (i64)) {
# CHECK: %[[VAL_22:.*]] = arith.cmpi slt, %[[VAL_21]], %[[VAL_3]] : i64
# CHECK: cc.condition %[[VAL_22]](%[[VAL_21]] : i64)
# CHECK: } do {
# CHECK: ^bb0(%[[VAL_20:.*]]: i64):
# CHECK: %[[VAL_21:.*]] = cc.compute_ptr %[[VAL_9]]{{\[}}%[[VAL_20]]] : (!cc.ptr<!cc.array<i64 x 10>>, i64) -> !cc.ptr<i64>
# CHECK: %[[VAL_22:.*]] = cc.load %[[VAL_21]] : !cc.ptr<i64>
# CHECK: %[[VAL_23:.*]] = cc.load %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_24:.*]] = math.fpowi %[[VAL_23]], %[[VAL_3]] : f64, i64
# CHECK: %[[VAL_25:.*]] = arith.addf %[[VAL_23]], %[[VAL_24]] : f64
# CHECK: cc.store %[[VAL_25]], %[[VAL_7]] : !cc.ptr<f64>
# CHECK: ^bb0(%[[VAL_23:.*]]: i64):
# CHECK: %[[VAL_24:.*]] = cc.compute_ptr %[[VAL_9]]{{\[}}%[[VAL_23]]] : (!cc.ptr<!cc.array<i64 x 10>>, i64) -> !cc.ptr<i64>
# CHECK: %[[VAL_25:.*]] = cc.load %[[VAL_24]] : !cc.ptr<i64>
# CHECK: %[[VAL_26:.*]] = cc.load %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_27:.*]] = arith.cmpf ogt, %[[VAL_26]], %[[VAL_1]] : f64
# CHECK: cc.if(%[[VAL_27]]) {
# CHECK: cc.unwind_break %[[VAL_20]] : i64
# CHECK: %[[VAL_27:.*]] = math.fpowi %[[VAL_26]], %[[VAL_4]] : f64, i64
# CHECK: %[[VAL_28:.*]] = arith.addf %[[VAL_26]], %[[VAL_27]] : f64
# CHECK: cc.store %[[VAL_28]], %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_29:.*]] = cc.load %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_30:.*]] = arith.cmpf ogt, %[[VAL_29]], %[[VAL_1]] : f64
# CHECK: cc.if(%[[VAL_30]]) {
# CHECK: cc.unwind_break %[[VAL_23]] : i64
# CHECK: }
# CHECK: %[[VAL_28:.*]] = cc.load %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_29:.*]] = arith.remui %[[VAL_22]], %[[VAL_6]] : i64
# CHECK: %[[VAL_30:.*]] = quake.extract_ref %[[VAL_8]]{{\[}}%[[VAL_29]]] : (!quake.veq<4>, i64) -> !quake.ref
# CHECK: quake.ry (%[[VAL_28]]) %[[VAL_30]] : (f64, !quake.ref) -> ()
# CHECK: cc.continue %[[VAL_20]] : i64
# CHECK: %[[VAL_31:.*]] = cc.load %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_32:.*]] = arith.remui %[[VAL_25]], %[[VAL_6]] : i64
# CHECK: %[[VAL_33:.*]] = quake.extract_ref %[[VAL_8]]{{\[}}%[[VAL_32]]] : (!quake.veq<4>, i64) -> !quake.ref
# CHECK: quake.ry (%[[VAL_31]]) %[[VAL_33]] : (f64, !quake.ref) -> ()
# CHECK: cc.continue %[[VAL_23]] : i64
# CHECK: } step {
# CHECK: ^bb0(%[[VAL_31:.*]]: i64):
# CHECK: %[[VAL_32:.*]] = arith.addi %[[VAL_31]], %[[VAL_4]] : i64
# CHECK: cc.continue %[[VAL_32]] : i64
# CHECK: ^bb0(%[[VAL_34:.*]]: i64):
# CHECK: %[[VAL_35:.*]] = arith.addi %[[VAL_34]], %[[VAL_2]] : i64
# CHECK: cc.continue %[[VAL_35]] : i64
# CHECK: } {invariant}
# CHECK: return
# CHECK: }
79 changes: 42 additions & 37 deletions python/tests/mlir/ast_continue.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,56 +35,61 @@ def kernel(x: float):
# CHECK-LABEL: func.func @__nvqpp__mlirgen__kernel(
# CHECK-SAME: %[[VAL_0:.*]]: f64) attributes {"cudaq-entrypoint"} {
# CHECK: %[[VAL_1:.*]] = arith.constant 1.000000e+01 : f64
# CHECK: %[[VAL_2:.*]] = arith.constant 10 : i64
# CHECK: %[[VAL_3:.*]] = arith.constant 2 : i64
# CHECK: %[[VAL_4:.*]] = arith.constant 1 : i64
# CHECK: %[[VAL_2:.*]] = arith.constant 1 : i64
# CHECK: %[[VAL_3:.*]] = arith.constant 10 : i64
# CHECK: %[[VAL_4:.*]] = arith.constant 2 : i64
# CHECK: %[[VAL_5:.*]] = arith.constant 0 : i64
# CHECK: %[[VAL_6:.*]] = arith.constant 4 : i64
# CHECK: %[[VAL_7:.*]] = cc.alloca f64
# CHECK: cc.store %[[VAL_0]], %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_8:.*]] = quake.alloca !quake.veq<4>
# CHECK: %[[VAL_9:.*]] = cc.alloca !cc.array<i64 x 10>
# CHECK: %[[VAL_10:.*]] = cc.loop while ((%[[VAL_11:.*]] = %[[VAL_5]]) -> (i64)) {
# CHECK: %[[VAL_12:.*]] = arith.cmpi slt, %[[VAL_11]], %[[VAL_2]] : i64
# CHECK: cc.condition %[[VAL_12]](%[[VAL_11]] : i64)
# CHECK: %[[VAL_10:.*]] = cc.alloca i64
# CHECK: cc.store %[[VAL_5]], %[[VAL_10]] : !cc.ptr<i64>
# CHECK: %[[VAL_11:.*]] = cc.loop while ((%[[VAL_12:.*]] = %[[VAL_5]]) -> (i64)) {
# CHECK: %[[VAL_13:.*]] = arith.cmpi slt, %[[VAL_12]], %[[VAL_3]] : i64
# CHECK: cc.condition %[[VAL_13]](%[[VAL_12]] : i64)
# CHECK: } do {
# CHECK: ^bb0(%[[VAL_13:.*]]: i64):
# CHECK: %[[VAL_14:.*]] = cc.compute_ptr %[[VAL_9]]{{\[}}%[[VAL_13]]] : (!cc.ptr<!cc.array<i64 x 10>>, i64) -> !cc.ptr<i64>
# CHECK: cc.store %[[VAL_13]], %[[VAL_14]] : !cc.ptr<i64>
# CHECK: cc.continue %[[VAL_13]] : i64
# CHECK: ^bb0(%[[VAL_14:.*]]: i64):
# CHECK: %[[VAL_15:.*]] = cc.load %[[VAL_10]] : !cc.ptr<i64>
# CHECK: %[[VAL_16:.*]] = cc.compute_ptr %[[VAL_9]]{{\[}}%[[VAL_15]]] : (!cc.ptr<!cc.array<i64 x 10>>, i64) -> !cc.ptr<i64>
# CHECK: cc.store %[[VAL_15]], %[[VAL_16]] : !cc.ptr<i64>
# CHECK: %[[VAL_17:.*]] = arith.addi %[[VAL_15]], %[[VAL_2]] : i64
# CHECK: cc.store %[[VAL_17]], %[[VAL_10]] : !cc.ptr<i64>
# CHECK: cc.continue %[[VAL_14]] : i64
# CHECK: } step {
# CHECK: ^bb0(%[[VAL_15:.*]]: i64):
# CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_15]], %[[VAL_4]] : i64
# CHECK: cc.continue %[[VAL_16]] : i64
# CHECK: ^bb0(%[[VAL_18:.*]]: i64):
# CHECK: %[[VAL_19:.*]] = arith.addi %[[VAL_18]], %[[VAL_2]] : i64
# CHECK: cc.continue %[[VAL_19]] : i64
# CHECK: } {invariant}
# CHECK: %[[VAL_17:.*]] = cc.loop while ((%[[VAL_18:.*]] = %[[VAL_5]]) -> (i64)) {
# CHECK: %[[VAL_19:.*]] = arith.cmpi slt, %[[VAL_18]], %[[VAL_2]] : i64
# CHECK: cc.condition %[[VAL_19]](%[[VAL_18]] : i64)
# CHECK: %[[VAL_20:.*]] = cc.loop while ((%[[VAL_21:.*]] = %[[VAL_5]]) -> (i64)) {
# CHECK: %[[VAL_22:.*]] = arith.cmpi slt, %[[VAL_21]], %[[VAL_3]] : i64
# CHECK: cc.condition %[[VAL_22]](%[[VAL_21]] : i64)
# CHECK: } do {
# CHECK: ^bb0(%[[VAL_20:.*]]: i64):
# CHECK: %[[VAL_21:.*]] = cc.compute_ptr %[[VAL_9]]{{\[}}%[[VAL_20]]] : (!cc.ptr<!cc.array<i64 x 10>>, i64) -> !cc.ptr<i64>
# CHECK: %[[VAL_22:.*]] = cc.load %[[VAL_21]] : !cc.ptr<i64>
# CHECK: %[[VAL_23:.*]] = cc.load %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_24:.*]] = math.fpowi %[[VAL_23]], %[[VAL_3]] : f64, i64
# CHECK: %[[VAL_25:.*]] = arith.addf %[[VAL_23]], %[[VAL_24]] : f64
# CHECK: cc.store %[[VAL_25]], %[[VAL_7]] : !cc.ptr<f64>
# CHECK: ^bb0(%[[VAL_23:.*]]: i64):
# CHECK: %[[VAL_24:.*]] = cc.compute_ptr %[[VAL_9]]{{\[}}%[[VAL_23]]] : (!cc.ptr<!cc.array<i64 x 10>>, i64) -> !cc.ptr<i64>
# CHECK: %[[VAL_25:.*]] = cc.load %[[VAL_24]] : !cc.ptr<i64>
# CHECK: %[[VAL_26:.*]] = cc.load %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_27:.*]] = arith.cmpf ogt, %[[VAL_26]], %[[VAL_1]] : f64
# CHECK: cc.if(%[[VAL_27]]) {
# CHECK: %[[VAL_28:.*]] = arith.remui %[[VAL_22]], %[[VAL_6]] : i64
# CHECK: %[[VAL_29:.*]] = quake.extract_ref %[[VAL_8]]{{\[}}%[[VAL_28]]] : (!quake.veq<4>, i64) -> !quake.ref
# CHECK: quake.x %[[VAL_29]] : (!quake.ref) -> ()
# CHECK: cc.unwind_continue %[[VAL_20]] : i64
# CHECK: %[[VAL_27:.*]] = math.fpowi %[[VAL_26]], %[[VAL_4]] : f64, i64
# CHECK: %[[VAL_28:.*]] = arith.addf %[[VAL_26]], %[[VAL_27]] : f64
# CHECK: cc.store %[[VAL_28]], %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_29:.*]] = cc.load %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_30:.*]] = arith.cmpf ogt, %[[VAL_29]], %[[VAL_1]] : f64
# CHECK: cc.if(%[[VAL_30]]) {
# CHECK: %[[VAL_31:.*]] = arith.remui %[[VAL_25]], %[[VAL_6]] : i64
# CHECK: %[[VAL_32:.*]] = quake.extract_ref %[[VAL_8]]{{\[}}%[[VAL_31]]] : (!quake.veq<4>, i64) -> !quake.ref
# CHECK: quake.x %[[VAL_32]] : (!quake.ref) -> ()
# CHECK: cc.unwind_continue %[[VAL_23]] : i64
# CHECK: }
# CHECK: %[[VAL_30:.*]] = cc.load %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_31:.*]] = arith.remui %[[VAL_22]], %[[VAL_6]] : i64
# CHECK: %[[VAL_32:.*]] = quake.extract_ref %[[VAL_8]]{{\[}}%[[VAL_31]]] : (!quake.veq<4>, i64) -> !quake.ref
# CHECK: quake.ry (%[[VAL_30]]) %[[VAL_32]] : (f64, !quake.ref) -> ()
# CHECK: cc.continue %[[VAL_20]] : i64
# CHECK: %[[VAL_33:.*]] = cc.load %[[VAL_7]] : !cc.ptr<f64>
# CHECK: %[[VAL_34:.*]] = arith.remui %[[VAL_25]], %[[VAL_6]] : i64
# CHECK: %[[VAL_35:.*]] = quake.extract_ref %[[VAL_8]]{{\[}}%[[VAL_34]]] : (!quake.veq<4>, i64) -> !quake.ref
# CHECK: quake.ry (%[[VAL_33]]) %[[VAL_35]] : (f64, !quake.ref) -> ()
# CHECK: cc.continue %[[VAL_23]] : i64
# CHECK: } step {
# CHECK: ^bb0(%[[VAL_33:.*]]: i64):
# CHECK: %[[VAL_34:.*]] = arith.addi %[[VAL_33]], %[[VAL_4]] : i64
# CHECK: cc.continue %[[VAL_34]] : i64
# CHECK: ^bb0(%[[VAL_36:.*]]: i64):
# CHECK: %[[VAL_37:.*]] = arith.addi %[[VAL_36]], %[[VAL_2]] : i64
# CHECK: cc.continue %[[VAL_37]] : i64
# CHECK: } {invariant}
# CHECK: return
# CHECK: }
18 changes: 9 additions & 9 deletions python/tests/mlir/ast_decrementing_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def test(q: int, p: int):
# CHECK-LABEL: func.func @__nvqpp__mlirgen__test(
# CHECK-SAME: %[[VAL_0:.*]]: i64,
# CHECK-SAME: %[[VAL_1:.*]]: i64) attributes {"cudaq-entrypoint"} {
# CHECK: %[[VAL_2:.*]] = arith.constant 0 : i64
# CHECK: %[[VAL_3:.*]] = arith.constant -1 : i64
# CHECK: %[[VAL_4:.*]] = arith.constant 1 : i64
# CHECK: %[[VAL_2:.*]] = arith.constant 1 : i64
# CHECK: %[[VAL_3:.*]] = arith.constant 0 : i64
# CHECK: %[[VAL_4:.*]] = arith.constant -1 : i64
# CHECK: %[[VAL_5:.*]] = cc.alloca i64
# CHECK: cc.store %[[VAL_0]], %[[VAL_5]] : !cc.ptr<i64>
# CHECK: %[[VAL_6:.*]] = cc.alloca i64
Expand All @@ -45,26 +45,26 @@ def test(q: int, p: int):
# CHECK: %[[VAL_11:.*]] = math.absi %[[VAL_10]] : i64
# CHECK: %[[VAL_12:.*]] = cc.alloca i64{{\[}}%[[VAL_11]] : i64]
# CHECK: %[[VAL_13:.*]] = cc.alloca i64
# CHECK: cc.store %[[VAL_2]], %[[VAL_13]] : !cc.ptr<i64>
# CHECK: cc.store %[[VAL_3]], %[[VAL_13]] : !cc.ptr<i64>
# CHECK: %[[VAL_14:.*]] = cc.loop while ((%[[VAL_15:.*]] = %[[VAL_8]]) -> (i64)) {
# CHECK: %[[VAL_16:.*]] = arith.cmpi sgt, %[[VAL_15]], %[[VAL_9]] : i64
# CHECK: cc.condition %[[VAL_16]](%[[VAL_15]] : i64)
# CHECK: } do {
# CHECK: ^bb0(%[[VAL_17:.*]]: i64):
# CHECK: %[[VAL_18:.*]] = cc.load %[[VAL_13]] : !cc.ptr<i64>
# CHECK: %[[VAL_19:.*]] = arith.muli %[[VAL_18]], %[[VAL_3]] : i64
# CHECK: %[[VAL_19:.*]] = arith.muli %[[VAL_18]], %[[VAL_4]] : i64
# CHECK: %[[VAL_20:.*]] = arith.addi %[[VAL_8]], %[[VAL_19]] : i64
# CHECK: %[[VAL_21:.*]] = cc.compute_ptr %[[VAL_12]]{{\[}}%[[VAL_18]]] : (!cc.ptr<!cc.array<i64 x ?>>, i64) -> !cc.ptr<i64>
# CHECK: cc.store %[[VAL_20]], %[[VAL_21]] : !cc.ptr<i64>
# CHECK: %[[VAL_22:.*]] = arith.addi %[[VAL_18]], %[[VAL_4]] : i64
# CHECK: %[[VAL_22:.*]] = arith.addi %[[VAL_18]], %[[VAL_2]] : i64
# CHECK: cc.store %[[VAL_22]], %[[VAL_13]] : !cc.ptr<i64>
# CHECK: cc.continue %[[VAL_17]] : i64
# CHECK: } step {
# CHECK: ^bb0(%[[VAL_23:.*]]: i64):
# CHECK: %[[VAL_24:.*]] = arith.addi %[[VAL_23]], %[[VAL_3]] : i64
# CHECK: %[[VAL_24:.*]] = arith.addi %[[VAL_23]], %[[VAL_4]] : i64
# CHECK: cc.continue %[[VAL_24]] : i64
# CHECK: } {invariant}
# CHECK: %[[VAL_25:.*]] = cc.loop while ((%[[VAL_26:.*]] = %[[VAL_2]]) -> (i64)) {
# CHECK: %[[VAL_25:.*]] = cc.loop while ((%[[VAL_26:.*]] = %[[VAL_3]]) -> (i64)) {
# CHECK: %[[VAL_27:.*]] = arith.cmpi slt, %[[VAL_26]], %[[VAL_11]] : i64
# CHECK: cc.condition %[[VAL_27]](%[[VAL_26]] : i64)
# CHECK: } do {
Expand All @@ -76,7 +76,7 @@ def test(q: int, p: int):
# CHECK: cc.continue %[[VAL_28]] : i64
# CHECK: } step {
# CHECK: ^bb0(%[[VAL_32:.*]]: i64):
# CHECK: %[[VAL_33:.*]] = arith.addi %[[VAL_32]], %[[VAL_4]] : i64
# CHECK: %[[VAL_33:.*]] = arith.addi %[[VAL_32]], %[[VAL_2]] : i64
# CHECK: cc.continue %[[VAL_33]] : i64
# CHECK: } {invariant}
# CHECK: return
Expand Down
4 changes: 3 additions & 1 deletion python/tests/mlir/ast_elif.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def cost(thetas: np.ndarray): # can pass 1D ndarray or list
rx(theta, q[i % 4])

print(cost)
cost(np.asarray([1., 2., 3., 4., 5., 6.]))
## [SKIP_TEST] : Following gives as error on 'python/cudaq/kernel/utils.py:176: ValueError'
## ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
# cost(np.asarray([1., 2., 3., 4., 5., 6.]))
khalatepradnya marked this conversation as resolved.
Show resolved Hide resolved
cost([1., 2., 3., 4., 5., 6.])


Expand Down
13 changes: 9 additions & 4 deletions python/tests/mlir/ast_for_stdvec.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def cost(thetas: np.ndarray): # can pass 1D ndarray or list
i += 1

print(cost)
cost(np.asarray([1., 2., 3., 4.]))
## [SKIP_TEST] : Following gives as error on 'python/cudaq/kernel/utils.py:176: ValueError'
## ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
# cost(np.asarray([1., 2., 3., 4.]))


# CHECK-LABEL: func.func @__nvqpp__mlirgen__cost(
Expand All @@ -49,11 +51,14 @@ def cost(thetas: np.ndarray): # can pass 1D ndarray or list
# CHECK: %[[VAL_13:.*]] = cc.load %[[VAL_4]] : !cc.ptr<i64>
# CHECK: %[[VAL_14:.*]] = quake.extract_ref %[[VAL_3]]{{\[}}%[[VAL_13]]] : (!quake.veq<4>, i64) -> !quake.ref
# CHECK: quake.ry (%[[VAL_12]]) %[[VAL_14]] : (f64, !quake.ref) -> ()
# CHECK: %[[VAL_15:.*]] = cc.load %[[VAL_4]] : !cc.ptr<i64>
# CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_15]], %[[VAL_1]] : i64
# CHECK: cc.store %[[VAL_16]], %[[VAL_4]] : !cc.ptr<i64>
# CHECK: cc.continue %[[VAL_9]] : i64
# CHECK: } step {
# CHECK: ^bb0(%[[VAL_15:.*]]: i64):
# CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_15]], %[[VAL_1]] : i64
# CHECK: cc.continue %[[VAL_16]] : i64
# CHECK: ^bb0(%[[VAL_17:.*]]: i64):
# CHECK: %[[VAL_18:.*]] = arith.addi %[[VAL_17]], %[[VAL_1]] : i64
# CHECK: cc.continue %[[VAL_18]] : i64
# CHECK: } {invariant}
# CHECK: return
# CHECK: }
Loading
Loading