Skip to content

[mlir] Inconsistent results for linalg.generic #129414

Closed
@AnonymousBugreporter1

Description

@AnonymousBugreporter1

I have the following MLIR program:
test.mlir:

#map = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
module {
  func.func @main() -> i32 {
    %c0_i32 = arith.constant 0 : i32
    %idx0 = index.constant 0
    %c1_i32 = arith.constant 1 : i32
    %alloc = memref.alloc() : memref<16x1x16xi32>
    linalg.fill ins(%c1_i32 : i32) outs(%alloc : memref<16x1x16xi32>)
    linalg.generic {indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel", "parallel"]} ins(%alloc : memref<16x1x16xi32>) outs(%alloc : memref<16x1x16xi32>) {
    ^bb0(%in: i32, %out: i32):
      linalg.yield %c0_i32 : i32
    }
    %0 = memref.load %alloc[%idx0, %idx0, %idx0] : memref<16x1x16xi32>
    vector.print %0 : i32
    return %0 : i32
  }
}

When I ran

/data/tmp/v0302/llvm-project/build/bin/mlir-opt \
--lower-affine --convert-index-to-llvm --convert-linalg-to-loops --convert-scf-to-cf --convert-arith-to-llvm --convert-vector-to-llvm --finalize-memref-to-llvm --convert-cf-to-llvm --convert-func-to-llvm --convert-arith-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v0302/llvm-project/build/bin/mlir-runner --entry-point-result=i32 --shared-libs=/data/tmp/v0302/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v0302/llvm-project/build/lib/libmlir_c_runner_utils.so

on the program, I got the result of:

0
0

However, when I ran

/data/tmp/v0302/llvm-project/build/bin/mlir-opt \
--canonicalize \
--lower-affine --convert-index-to-llvm --convert-linalg-to-loops --convert-scf-to-cf --convert-arith-to-llvm --convert-vector-to-llvm --finalize-memref-to-llvm --convert-cf-to-llvm --convert-func-to-llvm --convert-arith-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v0302/llvm-project/build/bin/mlir-runner --entry-point-result=i32 --shared-libs=/data/tmp/v0302/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v0302/llvm-project/build/lib/libmlir_c_runner_utils.so

on the program, I got the result of:

1
1

The above two results seem to be inconsistent. I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused these results.

My git version is b6d5fa0.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions