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