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

Method __cloneOrGetFunction

python/cudaq/kernel/kernel_builder.py:600–622  ·  view source on GitHub ↗

Get a the function with the given name. If the function is already present in `currentModule`, just return it. Otherwise, determine if `target` is a builder or a decorator and merge its module into `currentModule`. Once merged, return the function (from the c

(self, astName, currentModule, target)

Source from the content-addressed store, hash-verified

598 return QuakeValue(value, self)
599
600 def __cloneOrGetFunction(self, astName, currentModule, target):
601 """
602 Get a the function with the given name.
603 If the function is already present in `currentModule`, just return it.
604 Otherwise, determine if `target` is a builder or a decorator and merge
605 its module into `currentModule`. Once merged, return the function (from
606 the current module!) and the current module.
607 """
608 thisSymbolTable = SymbolTable(currentModule.operation)
609 if astName in thisSymbolTable:
610 return thisSymbolTable[astName], currentModule
611 if isa_kernel_decorator(target):
612 otherModule = target.qkeModule
613 fulluniq = nvqppPrefix + target.uniqName
614 cudaq_runtime.updateModule(fulluniq, currentModule, otherModule)
615 fn = recover_func_op(currentModule, fulluniq)
616 assert fn and "function may not disappear from module"
617 return fn, currentModule
618 otherModule = target.module
619 cudaq_runtime.updateModule(target.funcName, currentModule, otherModule)
620 fn = recover_func_op(currentModule, target.funcName)
621 assert fn and "function may not disappear from module"
622 return fn, currentModule
623
624 def __addAllCalledFunctionsRecursively(self, otherFunc, currentModule,
625 otherModule):

Callers 1

Calls 2

isa_kernel_decoratorFunction · 0.85
recover_func_opFunction · 0.85

Tested by

no test coverage detected