Error when using both vector.outerproduct and

Hi, I tried to use vector.outerproduct and 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> %result, %a[%c0, %c0] : memref<?x?xf32>, vector<2x2xf32>

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 like memref<4x4xf32>

I hope someone could help me with this problem.

The fails to lower. If you run only -convert-vector-to-llvm, you’ll see it is still there. Look inside the conversion pattern to understand why it fails to apply.

Thanks for your reply.
I looked inside the conversion pattern from vector to llvm in ConvertVectorToLLVM.cpp. It seems current pattern doesn’t support the replacement of 2D load or store vector.

If so, maybe the Example 3 for in document is out-of-date.