[Mlir-commits] [mlir] Fixes in 'tosa.reshape' lowering and folder (PR #85798)

Rafael Ubal llvmlistbot at llvm.org
Sat Mar 23 09:50:15 PDT 2024


rafaelubalmw wrote:

As observed by @sabauma, 0D tensors were not properly handled. I updated the PR as follows:

- I added additional checks for this special case.

- I added the following unit tests:

  - `reshape_0d_up_s2s_explicit`
  - `reshape_0d_up_s2s_auto`
  - `reshape_0d_up_s2d_explicit`
  - `reshape_0d_up_s2d_auto`
  - `reshape_1d_down_s2s_explicit`
  - `reshape_1d_down_d2s_explicit`
  - `reshape_4d_down_d2s_explicit`

- The new code led me to the observation that bufferization does not properly handle a `tensor.collapse_shape` op producing a 0D tensor from a dynamically shaped one. It looks like `memref.collapse_shape` does not allow it. While the proper way to address this would involve releasing the `memref.collapse_shape` restriction and verifying correct bufferization for this case, I'll leave that as possible future work. For now, I just avoid this scenario by casting the input if necessary (see `inferReshapeInputType()`).

- I renamed all the type inference functions and slightly modified their interfaces for symmetry.

Who knew there was so much to consider for a simple tensor reshape... :) Please let me know what you think.


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


More information about the Mlir-commits mailing list