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

Function test_ctrl_swap

python/tests/mlir/ctrl_gates.py:278–293  ·  view source on GitHub ↗

Tests the compilation of the various overloads of `cswap` gates.

()

Source from the content-addressed store, hash-verified

276
277
278def test_ctrl_swap():
279 """
280 Tests the compilation of the various overloads of `cswap` gates.
281 """
282 kernel = cudaq.make_kernel()
283 controls_vector = [kernel.qalloc() for _ in range(3)]
284 controls_register = kernel.qalloc(3)
285 first = kernel.qalloc()
286 second = kernel.qalloc()
287
288 kernel.cswap(controls_vector, first, second)
289 kernel.cswap(controls_register, first, second)
290 kernel.cswap([controls_vector[0], controls_vector[1], controls_register],
291 first, second)
292
293 print(kernel)
294
295
296# CHECK-LABEL: test_ctrl_swap

Callers

nothing calls this directly

Calls 4

cswapMethod · 0.80
rangeFunction · 0.50
printFunction · 0.50
qallocMethod · 0.45

Tested by

no test coverage detected