MCPcopy Create free account
hub / github.com/apache/tvm / GlobalVar

Class GlobalVar

python/tvm/ir/expr.py:66–108  ·  view source on GitHub ↗

A global variable in the IR. GlobalVar is used to refer to the global functions stored in the IRModule. Parameters ---------- name_hint: str The name of the variable.

Source from the content-addressed store, hash-verified

64
65@tvm_ffi.register_object("ir.GlobalVar")
66class GlobalVar(RelaxExpr):
67 """A global variable in the IR.
68
69 GlobalVar is used to refer to the global functions
70 stored in the IRModule.
71
72 Parameters
73 ----------
74 name_hint: str
75 The name of the variable.
76 """
77
78 name_hint: str
79
80 def __init__(self, name_hint: str):
81 self.__init_handle_by_constructor__(_ffi_api.GlobalVar, name_hint)
82
83 def __call__(self, *args: RelaxExpr) -> BaseExpr:
84 """Call the global variable.
85
86 Parameters
87 ----------
88 args: List[RelaxExpr]
89 The arguments to the call.
90
91 Returns
92 -------
93 call: BaseExpr
94 A call taking the variable as a function.
95 """
96 # pylint: disable=import-outside-toplevel
97
98 # TODO(@relax-team): replace with Relax base class after it's introduced
99 if all(isinstance(x, RelaxExpr) for x in args):
100 from tvm import relax
101
102 return relax.Call(self, args)
103
104 elif all(isinstance(x, Number | PrimExpr) for x in args):
105 return tvm.tirx.call_tir(self, *args)
106
107 arg_types = [type(x) for x in args]
108 raise RuntimeError(f"Do not know how to handle GlobalVar.__call__ for types {arg_types}")
109
110
111@tvm_ffi.register_object("ir.Range")

Callers 1

decorator_wrapperFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…