[Mlir-commits] [mlir] [mlir][vector] Determine vector sizes from the result shape in the ca… (PR #88249)

Han-Chung Wang llvmlistbot at llvm.org
Mon Apr 15 09:48:56 PDT 2024


================
@@ -1525,6 +1534,20 @@ vectorizeAsTensorPackOp(RewriterBase &rewriter, tensor::PackOp packOp,
   (void)status; // prevent unused variable warning on non-assert builds.
   assert(succeeded(status) && "failed to reify result shapes");
 
+  ArrayRef<int64_t> resultTensorShape = packOp.getDestType().getShape();
+  bool doMasking = true;
+
+  // If the input vector sizes are not provided, then the vector sizes are
+  // determined by the result tensor shape. In case the vector sizes aren't
+  // provided, we update the inBounds attribute instead of masking.
+  if (inputVectorSizes.empty()) {
+    // Make sure that the result tensor shape is static.
+    if (ShapedType::isDynamicShape(resultTensorShape))
+      return failure();
----------------
hanhanW wrote:

I think this kind of check should be in `vectorizePackOpPrecondition`, so we don't create any operations in this case. Also, we need to check if source shape is dynamic or not. We could have `tensor.pack ... : tensor<?xf32> -> tensor<4x16xf32>`. To have the check simpler, you can have `op.getDestType.hasStaticShape()`. (same for source check).

Please also add a negative test about non-static source cases, e.g., `tensor<?xf32> -> tensor<4x16xf32>`.

https://github.com/llvm/llvm-project/pull/88249


More information about the Mlir-commits mailing list