From fbbf0e4113818f7ace97e4804679d579f8144a27 Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Tue, 4 Nov 2025 16:22:58 -0500 Subject: [PATCH 1/8] [mlir][vector] Use getShapeForUnroll's default implementation. --- mlir/include/mlir/Dialect/Vector/IR/VectorOps.td | 2 +- mlir/lib/Dialect/Vector/IR/VectorOps.cpp | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td index 43172ff2082df..ccea764cfc579 100644 --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td @@ -361,7 +361,7 @@ def Vector_MultiDimReductionOp : def Vector_BroadcastOp : Vector_Op<"broadcast", [Pure, - DeclareOpInterfaceMethods, + DeclareOpInterfaceMethods, DeclareOpInterfaceMethods, PredOpTrait<"source operand and result have same element type", TCresVTEtIsSameAsOpBase<0, 0>>]>, diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp index daef0ba02100a..3e125e5c1f37b 100644 --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -2782,10 +2782,6 @@ void BroadcastOp::inferResultRanges(ArrayRef argRanges, setResultRanges(getResult(), argRanges.front()); } -std::optional> BroadcastOp::getShapeForUnroll() { - return llvm::to_vector<4>(getResultVectorType().getShape()); -} - /// Return the dimensions of the result vector that were formerly ones in the /// source tensor and thus correspond to "dim-1" broadcasting. static llvm::SetVector From 1964d161457e71208189065fc3cf82f2341e26e7 Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Tue, 4 Nov 2025 16:33:14 -0500 Subject: [PATCH 2/8] [mlir][vector] Use getShapeForUnroll's default implementation. --- mlir/include/mlir/Dialect/Vector/IR/VectorOps.td | 2 +- mlir/lib/Dialect/Vector/IR/VectorOps.cpp | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td index ccea764cfc579..1d3f70a9813f7 100644 --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td @@ -2758,7 +2758,7 @@ def Vector_MaskOp : Vector_Op<"mask", [ def Vector_TransposeOp : Vector_Op<"transpose", [Pure, DeclareOpInterfaceMethods, - DeclareOpInterfaceMethods, + DeclareOpInterfaceMethods, PredOpTrait<"operand and result have same element type", TCresVTEtIsSameAsOpBase<0, 0>>]> { let summary = "vector transpose operation"; diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp index 3e125e5c1f37b..2d5580ec0ff81 100644 --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -6716,10 +6716,6 @@ LogicalResult vector::TransposeOp::verify() { return success(); } -std::optional> TransposeOp::getShapeForUnroll() { - return llvm::to_vector<4>(getResultVectorType().getShape()); -} - void TransposeOp::inferResultRanges(ArrayRef argRanges, SetIntRangeFn setResultRanges) { setResultRanges(getResult(), argRanges.front()); From a0c6e4f90d38ab2609ebfce99fc1b28c623aeb11 Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Tue, 4 Nov 2025 16:39:13 -0500 Subject: [PATCH 3/8] [mlir][vector] Use getShapeForUnroll's default implementation. --- mlir/include/mlir/Dialect/Vector/IR/VectorOps.td | 2 +- mlir/lib/Dialect/Vector/IR/VectorOps.cpp | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td index 1d3f70a9813f7..fd6196a156d0f 100644 --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td @@ -2057,7 +2057,7 @@ def Vector_GatherOp : Vector_Op<"gather", [ DeclareOpInterfaceMethods, DeclareOpInterfaceMethods, - DeclareOpInterfaceMethods, + DeclareOpInterfaceMethods DeclareOpInterfaceMethods ]>, Arguments<(ins Arg, "", [MemRead]>:$base, diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp index 2d5580ec0ff81..cac8defb4d078 100644 --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -5982,10 +5982,6 @@ Type GatherOp::getExpectedMaskType() { vecType.getScalableDims()); } -std::optional> GatherOp::getShapeForUnroll() { - return llvm::to_vector<4>(getVectorType().getShape()); -} - /// Cheeck if `indexVec` is constant 1D vec of consecutive values [0, 1, 2, ...] static LogicalResult isZeroBasedContiguousSeq(Value indexVec) { auto vecType = dyn_cast(indexVec.getType()); From a6cbe0b42db5de0609455d3b1b575c006f6d3e4d Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Tue, 4 Nov 2025 16:43:37 -0500 Subject: [PATCH 4/8] [mlir][vector] Use getShapeForUnroll's default implementation. --- mlir/include/mlir/Dialect/Vector/IR/VectorOps.td | 2 +- mlir/lib/Dialect/Vector/IR/VectorOps.cpp | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td index fd6196a156d0f..fa613a86ad793 100644 --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td @@ -732,7 +732,7 @@ def Vector_ExtractOp : def Vector_FMAOp : Op, - DeclareOpInterfaceMethods + DeclareOpInterfaceMethods ] # ElementwiseMappable.traits>, Arguments<(ins VectorOfAnyRankOf<[AnyFloat]>:$lhs, VectorOfAnyRankOf<[AnyFloat]>:$rhs, diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp index cac8defb4d078..b56e98dd6b595 100644 --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -2374,14 +2374,6 @@ static void populateFromInt64AttrArray(ArrayAttr arrayAttr, results.push_back(llvm::cast(attr).getInt()); } -//===----------------------------------------------------------------------===// -// FmaOp -//===----------------------------------------------------------------------===// - -std::optional> FMAOp::getShapeForUnroll() { - return llvm::to_vector<4>(getVectorType().getShape()); -} - //===----------------------------------------------------------------------===// // ToElementsOp //===----------------------------------------------------------------------===// From cd648dac74e3d607e4bf13c3e8bc7c65b0d5c698 Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Tue, 4 Nov 2025 16:47:12 -0500 Subject: [PATCH 5/8] [mlir][vector] Use getShapeForUnroll's default implementation. --- mlir/include/mlir/Dialect/Vector/IR/VectorOps.td | 2 +- mlir/lib/Dialect/Vector/IR/VectorOps.cpp | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td index fa613a86ad793..a85ea2e128e1f 100644 --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td @@ -1245,7 +1245,7 @@ def Vector_ExtractStridedSliceOp : def Vector_TransferReadOp : Vector_Op<"transfer_read", [ DeclareOpInterfaceMethods, - DeclareOpInterfaceMethods, + DeclareOpInterfaceMethods, DeclareOpInterfaceMethods, DeclareOpInterfaceMethods, DeclareOpInterfaceMethods, diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp index b56e98dd6b595..f126f8dd6c4dd 100644 --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -5088,10 +5088,6 @@ OpFoldResult TransferReadOp::fold(FoldAdaptor) { return OpFoldResult(); } -std::optional> TransferReadOp::getShapeForUnroll() { - return llvm::to_vector<4>(getVectorType().getShape()); -} - void TransferReadOp::getEffects( SmallVectorImpl> &effects) { From 5103187a4f7b4676bc2125297a632b1d8419f9be Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Tue, 4 Nov 2025 17:12:57 -0500 Subject: [PATCH 6/8] [mlir][vector] Use getShapeForUnroll's default implementation. --- mlir/include/mlir/Dialect/Vector/IR/VectorOps.td | 2 +- mlir/lib/Dialect/Vector/IR/VectorOps.cpp | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td index a85ea2e128e1f..acfa578a184b8 100644 --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td @@ -1653,7 +1653,7 @@ def Vector_TransferWriteOp : } def Vector_LoadOp : Vector_Op<"load", [ - DeclareOpInterfaceMethods, + DeclareOpInterfaceMethods, DeclareOpInterfaceMethods, DeclareOpInterfaceMethods ]> { diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp index f126f8dd6c4dd..b030b060c6ba0 100644 --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -5762,10 +5762,6 @@ OpFoldResult LoadOp::fold(FoldAdaptor) { return OpFoldResult(); } -std::optional> LoadOp::getShapeForUnroll() { - return llvm::to_vector<4>(getVectorType().getShape()); -} - FailureOr>> LoadOp::bubbleDownCasts(OpBuilder &builder) { return mlir::detail::bubbleDownInPlaceMemorySpaceCastImpl(getBaseMutable(), From 71e53e7f294286f280b012367515f53a81b2cdb9 Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Tue, 4 Nov 2025 17:21:35 -0500 Subject: [PATCH 7/8] Fix documentation --- mlir/include/mlir/Interfaces/VectorInterfaces.td | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mlir/include/mlir/Interfaces/VectorInterfaces.td b/mlir/include/mlir/Interfaces/VectorInterfaces.td index 6838c16fdf0fe..1223f5c0704ab 100644 --- a/mlir/include/mlir/Interfaces/VectorInterfaces.td +++ b/mlir/include/mlir/Interfaces/VectorInterfaces.td @@ -24,9 +24,8 @@ def VectorUnrollOpInterface : OpInterface<"VectorUnrollOpInterface"> { let methods = [ InterfaceMethod< /*desc=*/[{ - Return the shape ratio of unrolling to the target vector shape - `targetShape`. Return `std::nullopt` if the op cannot be unrolled to the - target vector shape. + Return the shape of the vector of this operation, which may be used to decide unrolling factors. + Return std::nullopt if the op is not applicable for unrolling. }], /*retTy=*/"::std::optional<::llvm::SmallVector>", /*methodName=*/"getShapeForUnroll", From 200773d78f4e57baf5d02b9531d97a289012399a Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Thu, 6 Nov 2025 15:23:07 -0500 Subject: [PATCH 8/8] Fix rebase --- mlir/include/mlir/Dialect/Vector/IR/VectorOps.td | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td index acfa578a184b8..a1c5298629e58 100644 --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td @@ -2057,7 +2057,7 @@ def Vector_GatherOp : Vector_Op<"gather", [ DeclareOpInterfaceMethods, DeclareOpInterfaceMethods, - DeclareOpInterfaceMethods + DeclareOpInterfaceMethods, DeclareOpInterfaceMethods ]>, Arguments<(ins Arg, "", [MemRead]>:$base,