[Mlir-commits] [mlir] [mlir] Handle arith.const expr in dispatchIndexOpFoldResult func (PR #122432)

Matthias Springer llvmlistbot at llvm.org
Wed Jan 15 00:01:55 PST 2025


matthias-springer wrote:

OK, I understand now what you are trying to do. In my opinion, the input IR is invalid. We should make the verifier stricter to reject such ops.

Invalid:
```mlir
  %expand = tensor.expand_shape %collapse [[0], [1], [2, 3]]
              output_shape [%s0, %s1, %c2, %c3] : tensor<?x4x6xf32> into tensor<?x4x2x3xf32>
```

Valid:
```mlir
  %expand = tensor.expand_shape %collapse [[0], [1], [2, 3]]
              output_shape [%s0, 4, 2, 3] : tensor<?x4x6xf32> into tensor<?x4x2x3xf32>
```

The valid IR works with `-test-tensor-transform-patterns=test-expand-shape-bubbling`.

As for the reason why the first one should be invalid and the second one is valid, take a look a this discussion: https://discourse.llvm.org/t/tensor-ops-with-dynamic-sizes-which-behaviour-is-more-correct/82612. We were discussing the same issue in the context of `tensor.pack` and came to that conclusion.


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


More information about the Mlir-commits mailing list