[Mlir-commits] [mlir] [mlir][tensor] Remove assertion in ExpandShapeOp::build (PR #91361)

Gaurav Shukla llvmlistbot at llvm.org
Tue May 7 11:40:59 PDT 2024


Shukla-Gaurav wrote:

> Sorry that my comment was not clear.. It is true that it is hard to test c++ builder code. My point is that the build methods and verify methods should be aligned in some sense. It is okay to generate invalid op, but the verifier should signal it. In the case we've seen in torch-mlir repo, it is generating something like:
> 
> ```mlir
> tensor.expand_shape %arg0 [[0, 1]] output_shape [%sz0, %sz1] : tensor<?xf32> into tensor<?x?xf32>
> ```
> 
> So I'd suggest add the invalid op to `invalid.mlir`, and signal some errors from the verifier. I'm concerned that an invalid op is generated silently but not captured. With the test, at least we can inform users that such invalid op is generated.

Actually, this IR is not invalid anymore(https://github.com/llvm/llvm-project/pull/90040). This indicates that we are calling the wrong build method(that's why the assertion). We need to raise some sort of signal in place of assertion(maybe in follow up PR). 
Also tosa.reshape lowering needs to be fixed for such cases. 

https://github.com/llvm/llvm-project/pull/91361


More information about the Mlir-commits mailing list