Hello,
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,
%A:memref<?xf32>,
%C:memref<vector<8xf32>>) {
%ascalar0 = memref.load %A[%i] : memref<?xf32>
%a0 = vector.broadcast %ascalar0 : f32 to vector<8xf32>
affine.store %a0, %C[] : memref<vector<8xf32>>
return
}
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?
D.