[Mlir-commits] [mlir] [Linalg][Vectorization] Add support for linalg vectorization of a tensor.extract case (PR #107922)
Nirvedh Meshram
llvmlistbot at llvm.org
Tue Sep 17 10:45:03 PDT 2024
================
@@ -253,6 +253,54 @@ module attributes {transform.with_named_sequence} {
transform.yield
}
}
+
+// -----
+
+#map = affine_map<(d0, d1) -> (d0, d1)>
+#map1 = affine_map<(d0, d1, d2) -> (d0 + d1 + d2)>
+func.func @vectorize_nd_tensor_extract_transfer_without_outer_unit_dim(%arg0: tensor<8x128x768xf32>, %arg1 : index) -> tensor<8x1xf32> {
+ %c0 = arith.constant 0 : index
+ %0 = tensor.empty() : tensor<8x1xf32>
+ %1 = linalg.generic {
+ indexing_maps = [#map],
+ iterator_types = ["parallel", "parallel"]
+ } outs(%0 : tensor<8x1xf32>) {
+ ^bb0(%arg5: f32):
+ %2 = linalg.index 0 : index
+ %3 = linalg.index 1 : index
+ %4 = affine.apply #map1(%arg1, %3, %arg1)
+ %extracted = tensor.extract %arg0[%2, %c0, %4] : tensor<8x128x768xf32>
----------------
nirvedhmeshram wrote:
> the [test](https://github.com/llvm/llvm-project/blob/69f3244da76586be393d1e97b01660c6f03d666c/mlir/test/Dialect/Linalg/vectorize-tensor-extract.mlir#L112-L142) that I added should fail with your change - do you see why it didn't?
I think its becuase I had guards [here](https://github.com/llvm/llvm-project/pull/107922/files#diff-be7661e240d890a641a87f194bbb12e84a340b4a7f408865d5b89082123e24fbR1084-R1092) to not do anything for that case
> Hopefully this makes sense, but please let me know if not. This is quite convoluted stuff (mea culpa) and I really appreciate you fixing this
I think that does make sense to me, let me try to add the correct check.
https://github.com/llvm/llvm-project/pull/107922
More information about the Mlir-commits
mailing list