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

Method processQuakeCtor

python/cudaq/kernel/ast_bridge.py:2679–2711  ·  view source on GitHub ↗
(opName,
                             pyArgs,
                             isCtrl,
                             isAdj,
                             numParams=0,
                             numTargets=1)

Source from the content-addressed store, hash-verified

2677 opCtor(*args, controls, broadcast(target), **kwargs)
2678
2679 def processQuakeCtor(opName,
2680 pyArgs,
2681 isCtrl,
2682 isAdj,
2683 numParams=0,
2684 numTargets=1):
2685 kwargs = {}
2686 if isCtrl:
2687 argGroups = [(numParams, numParams), (1, -1),
2688 (numTargets, numTargets)]
2689 # FIXME: we could allow this as long as we have 1 target
2690 kwargs['broadcast'] = False
2691 elif numTargets == 1:
2692 # when we have a single target and no controls, we generally
2693 # support any version of `x(qubit)`, `x(qvector)`, `x(q, r)`
2694 argGroups = [(numParams, numParams), 0, (1, -1)]
2695 else:
2696 argGroups = [(numParams, numParams), 0,
2697 (numTargets, numTargets)]
2698 kwargs['broadcast'] = False
2699
2700 params, controls, targets = self.__groupValues(pyArgs, argGroups)
2701 if isCtrl:
2702 negatedControlQubits = getNegatedControlQubits(controls)
2703 kwargs['negated_qubit_controls'] = negatedControlQubits
2704 if isAdj:
2705 kwargs['is_adj'] = True
2706 params = [
2707 self.changeOperandToType(self.getFloatType(), param)
2708 for param in params
2709 ]
2710 processQuantumOperation(opName, controls, targets, [], params,
2711 **kwargs)
2712
2713 def processDecorator(name, path=None):
2714 from .kernel_decorator import isa_kernel_decorator

Callers

nothing calls this directly

Calls 3

__groupValuesMethod · 0.95
changeOperandToTypeMethod · 0.95
getFloatTypeMethod · 0.95

Tested by

no test coverage detected