Vector.broadcast lowered to std.splat, which is not accepted by mlir-translate


While advancing with my understanding of the vector dialect, I ran into the following issue: mlir-opt --convert-vector-to-llvm will translate vector.broadcast into std.splat, which mlir-translate does not accept as input. Here is a small function exhibiting the problem:

func @mytest(%i:index,
	     %C:memref<vector<8xf32>>) {
  %ascalar0 = memref.load %A[%i] : memref<?xf32>
  %a0 = vector.broadcast %ascalar0 : f32 to vector<8xf32> %a0, %C[] : memref<vector<8xf32>>

The compilation is done with:

mlir-opt --lower-affine --convert-scf-to-std --convert-std-to-llvm --convert-vector-to-llvm try.mlir | ~/llvm/bin/mlir-translate --mlir-to-llvmir

I have tried to add set --convert-vector-to-llvm="enable-avx512", the problem persists.

As far as I understand, there could be 2 solutions to this:

  • Assuming that a vector broadcast operation exists in LLVM IR, ensure that std.splat is translated to this operation.
  • Assuming that LLVM-level broadcast depends on the extension (in my case AVX2), ensure that --convert-vector-to-llvm can take an option allowing the activation of this extension. Currently, I found only --enable-avx512, and activating it did not allow code generation.

What am I doing wrong?

Order matters :wink:

Please try

mlir-opt --lower-affine --convert-scf-to-std --convert-vector-to-llvm --convert-std-to-llvm

before passing it to mlir-translate.

1 Like