[Mlir-commits] [mlir] [mlir][vector] Migrate drop-lead-unit-dim to shape_cast (PR #196206)

Erick Ochoa Lopez llvmlistbot at llvm.org
Thu May 7 06:30:25 PDT 2026


================
@@ -45,14 +50,81 @@ static VectorType trimLeadingOneDims(VectorType oldType) {
   return VectorType::get(newShape, oldType.getElementType(), newScalableDims);
 }
 
-/// Return a smallVector of size `rank` containing all zeros.
-static SmallVector<int64_t> splatZero(int64_t rank) {
-  return SmallVector<int64_t>(rank, 0);
+/// Returns `value` if it already has `newType`, otherwise inserts a
+/// vector.shape_cast to `newType`.
+static Value shapeCastVector(OpBuilder &b, Location loc, Value value,
+                             VectorType newType) {
+  if (value.getType() == newType)
+    return value;
+  return vector::ShapeCastOp::create(b, loc, newType, value);
+}
+
+static bool hasNonScalableUnitLeadingDims(VectorType type, int64_t dropCount) {
+  if (dropCount < 0 || dropCount > type.getRank())
+    return false;
----------------
amd-eochoalo wrote:

Nit: Same comment about bounds check being an assertion.

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


More information about the Mlir-commits mailing list