| Issue |
174540
|
| Summary |
[MLIR]Inconsistent results with `tensor.pad` when using `-normalize-memrefs`
|
| Labels |
mlir
|
| Assignees |
|
| Reporter |
BealZephyr
|
**test commit**: [5cfd02](https://github.com/llvm/llvm-project/commit/5cfd02f44a43a2e2a085a633b022a62f64ba2b93)
## Description:
Without `-normalize-memrefs`, the expected behavior is that only the extracted slice is padded correctly. However, when `-normalize-memrefs` is applied, the result seems to be incorrectly expanded, with extra padding values appearing in the output that should not be there.
## test case
```
module {
func.func private @printMemrefF32(tensor<*xf32>)
func.func @main() {
%0 = "tosa.const"() <{values = dense<6.394000e+01> : tensor<4x5xf32>}> : () -> tensor<4x5xf32>
%cst = arith.constant 3.804000e+01 : f32
%padded = tensor.pad %0 low[0, 0] high[7, 8] {
^bb0(%arg0: index, %arg1: index):
tensor.yield %cst : f32
} : tensor<4x5xf32> to tensor<11x13xf32>
%extracted_slice = tensor.extract_slice %padded[1, 2] [2, 1] [1, 1] : tensor<11x13xf32> to tensor<2x1xf32>
%cast = tensor.cast %extracted_slice : tensor<2x1xf32> to tensor<*xf32>
call @printMemrefF32(%cast) : (tensor<*xf32>) -> ()
return
}
}
```
## Command:
### 1. without `-normalize-memrefs`
#### cmd
```
mlir-opt test.mlir -tosa-to-linalg-pipeline -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries=1" \
-convert-linalg-to-affine-loops -lower-affine -convert-scf-to-cf -expand-strided-metadata -convert-to-llvm\
| mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project-latest/build/lib/libmlir_runner_utils.so
```
#### output:
```
[[63.94],
[63.94]]
```
### 2. With `-normalize-memrefs`
#### cmd
```
mlir-opt test.mlir -tosa-to-linalg-pipeline -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries=1" \
-convert-linalg-to-affine-loops -lower-affine -convert-scf-to-cf -expand-strided-metadata \
-normalize-memrefs -convert-to-llvm | mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project-latest/build/lib/libmlir_runner_utils.so
```
#### output:
```
[63.94, 63.94, 63.94, 63.94, 63.94, 38.04, 38.04, 38.04, 38.04, 38.04, 38.04, 38.04, 38.04, 63.94, 63.94, 63.94, 63.94, 63.94, 38.04, 38.04, 38.04, 38.04, 38.04, 38.04, 38.04, 38.04, 63.94, 63.94, 63.94]
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs