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

Function getMLIRContext

python/cudaq/kernel/utils.py:73–88  ·  view source on GitHub ↗

This code creates an MLIRContext singleton for this python process. We do not want to have a brand new context every time Python does something with a kernel.

()

Source from the content-addressed store, hash-verified

71
72
73def getMLIRContext():
74 """
75 This code creates an MLIRContext singleton for this python process. We do
76 not want to have a brand new context every time Python does something with a
77 kernel.
78 """
79 global cudaq__global_mlir_context
80 try:
81 cudaq__global_mlir_context
82 except NameError:
83 cudaq__global_mlir_context = Context()
84 register_all_dialects(cudaq__global_mlir_context)
85 quake.register_dialect(context=cudaq__global_mlir_context)
86 cc.register_dialect(context=cudaq__global_mlir_context)
87 cudaq_runtime.registerLLVMDialectTranslation(cudaq__global_mlir_context)
88 return cudaq__global_mlir_context
89
90
91class Initializer:

Callers 13

postJobFunction · 0.90
__init__Method · 0.85
compileMethod · 0.85
__init__Method · 0.85
initializeMethod · 0.85
get_callable_typeMethod · 0.85
get_lifted_typeMethod · 0.85
get_none_typeMethod · 0.85
process_argumentMethod · 0.85
toLocationMethod · 0.85

Calls 1

ContextClass · 0.90

Tested by

no test coverage detected