MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / _parse_and_assert_equal

Function _parse_and_assert_equal

python/tests/kernel/test_kernel_signature.py:58–77  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

56
57
58def _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
80def _make_kernel_ast(arg_types=None, return_type=None) -> ast.Module:

Callers 8

test_no_args_no_returnFunction · 0.85
test_single_int_argFunction · 0.85
test_single_float_argFunction · 0.85
test_multiple_mixed_argsFunction · 0.85
test_bool_returnFunction · 0.85
test_list_int_argFunction · 0.85

Calls 3

_get_ast_from_callableFunction · 0.85
parse_from_astMethod · 0.80
parse_from_mlirMethod · 0.80

Tested by

no test coverage detected