MCPcopy Index your code
hub / github.com/apache/tvm / IRModule

Class IRModule

python/tvm/ir/module.py:31–283  ·  view source on GitHub ↗

IRModule that holds functions and type definitions. IRModule is the basic unit for all IR transformations across the stack. Parameters ---------- functions: Optional[dict]. Map of global var to BaseFunc

Source from the content-addressed store, hash-verified

29
30@tvm_ffi.register_object("ir.IRModule")
31class IRModule(Node, Scriptable):
32 """IRModule that holds functions and type definitions.
33
34 IRModule is the basic unit for all IR transformations across the stack.
35
36 Parameters
37 ----------
38 functions: Optional[dict].
39 Map of global var to BaseFunc
40 """
41
42 def __init__(self, functions=None, attrs=None, global_infos=None):
43 if functions is None:
44 functions = {}
45 elif isinstance(functions, dict):
46 mapped_funcs = {}
47 for k, v in functions.items():
48 if isinstance(k, str):
49 k = _expr.GlobalVar(k)
50 if not isinstance(k, _expr.GlobalVar):
51 raise TypeError("Expect functions to be Dict[GlobalVar, Function]")
52 mapped_funcs[k] = v
53 functions = mapped_funcs
54
55 attrs = None if not attrs else attrs
56 if attrs is not None:
57 attrs = tvm.ir.make_node("ir.DictAttrs", **attrs)
58 if global_infos is None:
59 global_infos = {}
60 self.__init_handle_by_constructor__(
61 _ffi_api.IRModule,
62 functions,
63 attrs,
64 global_infos,
65 )
66 self.pyfuncs = {}
67
68 def clone(self) -> "IRModule":
69 return _ffi_api.Module_Clone(self)
70
71 def functions_items(self):
72 """Get items in self.functions.items() in alphabetical order.
73
74 Returns
75 -------
76 items: List[Tuple[GlobalVar, Function]]
77 The functions items.
78 """
79 items = list(self.functions.items())
80 items.sort(key=lambda item: str(item[0].name_hint))
81 return items
82
83 def __setitem__(self, var, val):
84 """Add a mapping to the module.
85
86 Parameters
87 ---------
88 var: GlobalVar

Callers 15

_filter_tirFunction · 0.90
__init__Method · 0.90
_parse_modFunction · 0.90
extract_tasksFunction · 0.90
_normalize_modFunction · 0.90
remove_global_symbolsFunction · 0.90
check_sketchesFunction · 0.90
test_extern_funcFunction · 0.90
_bad_matmul_moduleFunction · 0.90

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…