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

Function bind_for_value

python/tvm/tirx/script/parser/parser.py:134–167  ·  view source on GitHub ↗

Value binding methods when parsing for statement. e.g. binding i, j, k with T.grid(128, 128, 128), when parsing for i, j, k in T.grid(128, 128, 128). Parameters ---------- self : Parser The current parser. node : doc.expr The doc AST expression node for

(self: Parser, node: doc.expr, var_name: str, value: Any)

Source from the content-addressed store, hash-verified

132
133
134def bind_for_value(self: Parser, node: doc.expr, var_name: str, value: Any) -> Any:
135 """Value binding methods when parsing for statement.
136 e.g. binding i, j, k with T.grid(128, 128, 128), when parsing
137 for i, j, k in T.grid(128, 128, 128).
138
139 Parameters
140 ----------
141 self : Parser
142 The current parser.
143
144 node : doc.expr
145 The doc AST expression node for error reporting.
146
147 var_name : str
148 The variable name.
149
150 value : Any
151 The value to be bound with.
152
153 Returns
154 -------
155 res : Any
156 The bound value.
157 """
158 if isinstance(value, list | tuple | tvm.ir.Array):
159 for i, v in enumerate(value):
160 bind_for_value(self, node, f"{var_name}_{i}", v)
161 return value
162 elif isinstance(value, Var):
163 IRBuilder.name(var_name, value)
164 return value
165 else:
166 self.report_error(node, f"Do not know how to bind type: {type(value)} in for statement")
167 raise NotImplementedError
168
169
170def bind_assign_value(self: Parser, node: doc.expr, var_name: str, value: Any) -> Any:

Callers

nothing calls this directly

Calls 2

report_errorMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…