Add a shape constraint to this pattern Parameters ---------- shape: List[PrimExpr] Expected shape list Returns ------- result: ShapePattern The resulting ShapePattern Note ---- has_shape assum
(self, shape: list[PrimExpr])
| 143 | return has_dtype(dtype, self) |
| 144 | |
| 145 | def has_shape(self, shape: list[PrimExpr]) -> "ShapePattern": |
| 146 | """ |
| 147 | Add a shape constraint to this pattern |
| 148 | |
| 149 | Parameters |
| 150 | ---------- |
| 151 | shape: List[PrimExpr] |
| 152 | Expected shape list |
| 153 | |
| 154 | Returns |
| 155 | ------- |
| 156 | result: ShapePattern |
| 157 | The resulting ShapePattern |
| 158 | |
| 159 | Note |
| 160 | ---- |
| 161 | has_shape assumes that the matched relax.Expr only has one |
| 162 | output tensor. Use is_tuple for those with multiple outputs. |
| 163 | """ |
| 164 | if not isinstance(shape, list | tuple | tvm.ir.PrimExpr): |
| 165 | raise ValueError("has_shape takes a list or tuple as input.") |
| 166 | return ShapePattern(pattern=self, shape=shape) |
| 167 | |
| 168 | def match(self, expr, var2val: dict[Var, Expr] | None = None) -> bool: |
| 169 | """ |