llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.6k stars 11.82k forks source link

[MLIR]Lower affine successfully but the error message is still output #58651

Open BealZephyr opened 1 year ago

BealZephyr commented 1 year ago

When I use cmd mlir-opt temp.mlir -lower-affine, the lowering succeeds, but it outputs some errors.
Whether there is any problem with the diagnoser? I’m confused about this, why lowering can succeed despite the error reported by the diagnoser?

Minimized test case:

#map0 = affine_map<() -> (13)>
#map1 = affine_map<() -> (21)>
#map2 = affine_map<(d0)[s0] -> (d0 * s0)>
#map3 = affine_map<() -> (3)>
#map4 = affine_map<(d0)[s0] -> (d0 mod s0)>
#map5 = affine_map<(d0)[s0] -> (d0 floordiv s0)>
module {
  func.func @test_greater(%arg0: tensor<13x21x1xf32>, %arg1: tensor<13x21x3xf32>) {
    %4 = affine.apply #map0()
    %5 = affine.apply #map1()
    %6 = affine.apply #map2(%4)[%5]
    %7 = affine.apply #map3()
    %8 = affine.apply #map2(%6)[%7]
    affine.for %arg2 = 0 to %8 {
      %16 = affine.apply #map4(%arg2)[%7]
    }
    return
  }
}

The error information is like:

temp.mlir:15:13: error: semi-affine expressions (modulo by non-const) are not supported
      %16 = affine.apply #map4(%arg2)[%7]
            ^
#map = affine_map<(d0)[s0] -> (d0 mod s0)>
module {
  func.func @test_greater(%arg0: tensor<13x21x1xf32>, %arg1: tensor<13x21x3xf32>) {
    %c13 = arith.constant 13 : index
    %c21 = arith.constant 21 : index
    %0 = arith.muli %c13, %c21 : index
    %c3 = arith.constant 3 : index
    %1 = arith.muli %0, %c3 : index
    %c0 = arith.constant 0 : index
    %c819 = arith.constant 819 : index
    %c1 = arith.constant 1 : index
    scf.for %arg2 = %c0 to %c819 step %c1 {
      %2 = affine.apply #map(%arg2)[%c3]
    }
    return
  }
}

Test commit: #e6c23f4

llvmbot commented 1 year ago

@llvm/issue-subscribers-mlir-affine