[Mlir-commits] [mlir] [mlir][vector]advance support extract insert under dynamic case. (PR #121631)
lonely eagle
llvmlistbot at llvm.org
Sun Jan 5 17:34:33 PST 2025
linuxlonelyeagle wrote:
There is an error in the above program, I corrected it, the following program can be done with pipeline `mlir-opt vector-extract-insert.mlir -affine-loop-unroll=“unroll-full=true unroll-num-reps=10” -convert -arith-to-llvm -convert-vector-to-llvm` to `llvm dialect`.
```
func.func @main() -> i32 {
%c = arith.constant dense<0> : vector<32x1xi32>
%a = arith.constant dense<1> : vector<32x1xi32>
%b = arith.constant dense<1> : vector<1x1xi32>
%c_0 = arith.constant 0 : index
%y = affine.for %arg_0 = 0 to 32 iter_args(%it_0 = %c) -> vector<32x1xi32> {
%y_0 = affine.for %arg_1 = 0 to 1 iter_args(%it_1 = %it_0) -> vector<32x1xi32> {
%c_elem = vector.extract %it_1[%arg_0, %arg_1] : i32 from vector<32x1xi32>
%a_elem = vector.extract %a[%arg_0, %c_0] : i32 from vector<32x1xi32>
%b_elem = vector.extract %b[%arg_1, %c_0] : i32 from vector<1x1xi32>
%mul = arith.muli %a_elem, %b_elem : i32
%ret = arith.addi %mul, %c_elem : i32
%y_1 = vector.insert %ret, %it_1[%arg_0, %arg_1] : i32 into vector<32x1xi32>
affine.yield %y_1 : vector<32x1xi32>
}
affine.yield %y_0 : vector<32x1xi32>
}
vector.print %c : vector<32x1xi32>
vector.print %y : vector<32x1xi32>
%ret = arith.constant 0 : i32
return %ret : i32
}
```
Cc @Groverkss @ftynse @krzysz00
https://github.com/llvm/llvm-project/pull/121631
More information about the Mlir-commits
mailing list