Hi, I tried to use vector.outerproduct and vector.store in my program as followings:
func.func @main() {
%c0 = arith.constant 0 : index
%f1 = arith.constant 1.0 : f32
%m = arith.constant 2 : index
%n = arith.constant 2 : index
%a = memref.alloc (%m, %n) : memref<?x?xf32>
%v1 = vector.splat %f1 : vector<2xf32>
%v2 = vector.splat %f1 : vector<2xf32>
%v3 = vector.load %a[%c0, %c0] : memref<?x?xf32>, vector<2x2xf32>
%result = vector.outerproduct %v1, %v2, %v3 : vector<2xf32>, vector<2xf32>
vector.store %result, %a[%c0, %c0] : memref<?x?xf32>, vector<2x2xf32>
return
}
But it was weird that it couldn’t be compiled normally.
$ mlir-opt mlir-opt-16.0.0/test-outerproduct-store-2d.mlir -convert-linalg-to-loops -convert-linalg-to-llvm -convert-scf-to-cf -convert-vector-to-llvm -convert-func-to-llvm -convert-memref-to-llvm -reconcile-unrealized-casts
mlir-opt-16.0.0/test-outerproduct-store-2d.mlir:3:11: error: failed to legalize operation 'builtin.unrealized_conversion_cast' that was explicitly marked illegal
%c0 = arith.constant 0 : index
^
mlir-opt-16.0.0/test-outerproduct-store-2d.mlir:3:11: note: see current operation: %7 = "builtin.unrealized_conversion_cast"(%6) : (i64) -> index
I didn’t figure out why this error happened. Here are my observations.
- This problem comes from the pass corresponding to option
-reconcile-unrealized-casts
. - I tried with
-convert-arith-to-llvm
, but it failed. - This problem is not derived from the dynamic shpe. The same problem still occurs when I change the shape of
%a
to static shape likememref<4x4xf32>
I hope someone could help me with this problem.