Issue 203693
Summary [mlir][scf] scf-parallel-loop-tiling with no-min-max-bounds=true produces incorrect results
Labels mlir
Assignees
Reporter Avaneethk
    The no-min-max-bounds=true code path of scf-parallel-loop-tiling appears to
produce incorrect results.

The default affine.min-based tiling path produces the expected output,
while enabling no-min-max-bounds=true results in incorrect execution.

reproducer 
module {
  func.func private @printMemrefI32(tensor<*xi32>)
  func.func private @printMemrefF32(tensor<*xf32>)
  func.func @main() {
    %7 = "tosa.const"() <{values = dense<6220> : tensor<1x6x6xi32>}> : () -> tensor<1x6x6xi32>
    %9 = "tosa.const"() <{values = dense<-298> : tensor<1x6x6xi32>}> : () -> tensor<1x6x6xi32>
    %51 = tosa.bitwise_or %7, %9 : (tensor<1x6x6xi32>, tensor<1x6x6xi32>) -> tensor<1x6x6xi32>
    %cast = tensor.cast %51 : tensor<1x6x6xi32> to tensor<*xi32>
    call @printMemrefI32(%cast) : (tensor<*xi32>) -> ()
    return
 }
}

/wrk/open_contributions/llvm-project/build/bin/mlir-opt test2.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" | /wrk/open_contributions/llvm-project/build/bin/mlir-opt -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-parallel-loops            -convert-index-to-llvm -convert-arith-to-llvm --scf-parallel-loop-tiling="parallel-loop-tile-sizes=1,4 no-min-max-bounds=true"    --canonicalize --scf-parallel-loop-tiling="parallel-loop-tile-sizes=1,4 no-min-max-bounds=true"   -convert-scf-to-cf       -convert-arith-to-llvm -convert-cf-to-llvm  -finalize-memref-to-llvm   -convert-func-to-llvm -lower-affine  -convert-arith-to-llvm  -reconcile-unrealized-casts | timeout 10 /wrk/open_contributions/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void --shared-libs=/wrk/open_contributions/llvm-project/build/lib/libmlir_c_runner_utils.so --shared-libs=/wrk/open_contributions/llvm-project/build/lib/libmlir_runner_utils.so --shared-libs=/wrk/open_contributions/llvm-project/build/lib/libmlir_async_runtime.so

with no-min-max-bounds=true

output
[[[-290,    -290,    -290,    -290, -290,    -290], 
  [-290,    -290,    -290,    -290,    -290,    -290], 
 [-290,    -290,    -290,    -290,    -290,    -290], 
  [-290,    -290, -290,    -290,    -290,    -290], 
  [0,    0,    0,    0,    0,    0], 
 [0,    0,    2,    0,    0,    0]]]

with  no-min-max-bounds=false correct output

[[[-290,    -290,    -290,    -290,    -290,    -290], 
  [-290, -290,    -290,    -290,    -290,    -290], 
  [-290,    -290,    -290, -290,    -290,    -290], 
  [-290,    -290,    -290,    -290,    -290, -290], 
  [-290,    -290,    -290,    -290,    -290,    -290], 
  [-290, -290,    -290,    -290,    -290,    -290]]]

I see a different lowering with no-min-max-bounds=true in /wrk/open_contributions/llvm-project/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to