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

Function bind_with_value

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

Value binding methods when parsing with statement. e.g. binding i, j, k with T.grid(128, 128, 128), when parsing with T.grid(128, 128, 18) as i, j, k. 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

96
97
98def bind_with_value(self: Parser, node: doc.expr, var_name: str, value: Any) -> Any:
99 """Value binding methods when parsing with statement.
100 e.g. binding i, j, k with T.grid(128, 128, 128), when parsing
101 with T.grid(128, 128, 18) as i, j, k.
102
103 Parameters
104 ----------
105 self : Parser
106 The current parser.
107
108 node : doc.expr
109 The doc AST expression node for error reporting.
110
111 var_name : str
112 The variable name.
113
114 value : Any
115 The value to be bound with.
116
117 Returns
118 -------
119 res : Any
120 The bound value.
121 """
122 if isinstance(value, list | tuple):
123 for i, v in enumerate(value):
124 bind_with_value(self, node, f"{var_name}_{i}", v)
125 return value
126 elif isinstance(value, Buffer | Var):
127 IRBuilder.name(var_name, value)
128 return value
129 else:
130 self.report_error(node, f"Do not know how to bind type: {type(value)} in with statement")
131 raise NotImplementedError
132
133
134def bind_for_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…