Parse the given callable via both AST and MLIR routes, assert that the resulting signatures are identical, and return the signature for further assertions.
(fn)
| 56 | |
| 57 | |
| 58 | def _parse_and_assert_equal(fn): |
| 59 | """ |
| 60 | Parse the given callable via both AST and MLIR routes, |
| 61 | assert that the resulting signatures are identical, |
| 62 | and return the signature for further assertions. |
| 63 | """ |
| 64 | # Parse via AST |
| 65 | sig_a = KernelSignature.parse_from_ast(_get_ast_from_callable(fn), |
| 66 | fn.__name__) |
| 67 | # replace None with empty list for comparision with MLIR |
| 68 | sig_a.captured_args = [] |
| 69 | |
| 70 | # Parse via MLIR |
| 71 | decorated = cudaq.kernel(fn) |
| 72 | sig_m = KernelSignature.parse_from_mlir(decorated.qkeModule, |
| 73 | decorated.uniqName) |
| 74 | |
| 75 | assert sig_a == sig_m |
| 76 | |
| 77 | return sig_m |
| 78 | |
| 79 | |
| 80 | def _make_kernel_ast(arg_types=None, return_type=None) -> ast.Module: |
no test coverage detected