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)
| 132 | |
| 133 | |
| 134 | def 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 | |
| 170 | def bind_assign_value(self: Parser, node: doc.expr, var_name: str, value: Any) -> Any: |
nothing calls this directly
no test coverage detected
searching dependent graphs…