Skip to content

[mlir][nfc] Rename type constraint for scalable vectors #68808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/ArmSME/IR/ArmSMEOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ include "mlir/Interfaces/InferTypeOpInterface.td"

class SMETileType<Type datatype, list<int> dims, string description>
: ShapedContainerType<[datatype],
And<[IsVectorOfRankPred<[2]>, allDimsScalableVectorTypePred,
And<[IsVectorOfRankPred<[2]>, IsVectorTypeWithAllDimsScalablePred,
Copy link
Member

@MacDue MacDue Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required: The IsVectorOfRankPred<[2]> is redundant as the dims list always has two elements.

Suggested change
And<[IsVectorOfRankPred<[2]>, IsVectorTypeWithAllDimsScalablePred,
And<[IsVectorTypeWithAllDimsScalablePred,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, interesting! I will keep it as a useful bit of documentation.

IsVectorOfShape<dims>]>,
description>;

Expand Down
13 changes: 7 additions & 6 deletions mlir/include/mlir/IR/CommonTypeConstraints.td
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ def IsFixedVectorTypePred : CPred<[{::llvm::isa<::mlir::VectorType>($_self) &&
!::llvm::cast<VectorType>($_self).isScalable()}]>;

// Whether a type is a scalable VectorType.
def IsScalableVectorTypePred : CPred<[{::llvm::isa<::mlir::VectorType>($_self) &&
::llvm::cast<VectorType>($_self).isScalable()}]>;
def IsVectorTypeWithAnyDimScalablePred
: CPred<[{::llvm::isa<::mlir::VectorType>($_self) &&
::llvm::cast<VectorType>($_self).isScalable()}]>;

// Whether a type is a VectorType and all dimensions are scalable.
def allDimsScalableVectorTypePred : And<[
def IsVectorTypeWithAllDimsScalablePred : And<[
IsVectorTypePred,
CPred<[{::llvm::cast<::mlir::VectorType>($_self).allDimsScalable()}]>
]>;
Expand Down Expand Up @@ -401,7 +402,7 @@ class FixedVectorOf<list<Type> allowedTypes> :
"fixed-length vector", "::mlir::VectorType">;

class ScalableVectorOf<list<Type> allowedTypes> :
ShapedContainerType<allowedTypes, IsScalableVectorTypePred,
ShapedContainerType<allowedTypes, IsVectorTypeWithAnyDimScalablePred,
"scalable vector", "::mlir::VectorType">;

// Whether the number of elements of a vector is from the given
Expand All @@ -425,7 +426,7 @@ class IsFixedVectorOfRankPred<list<int> allowedRanks> :
// Whether the number of elements of a scalable vector is from the given
// `allowedRanks` list
class IsScalableVectorOfRankPred<list<int> allowedRanks> :
And<[IsScalableVectorTypePred,
And<[IsVectorTypeWithAnyDimScalablePred,
Or<!foreach(allowedlength, allowedRanks,
CPred<[{::llvm::cast<::mlir::VectorType>($_self).getRank()
== }]
Expand Down Expand Up @@ -475,7 +476,7 @@ class IsFixedVectorOfLengthPred<list<int> allowedLengths> :
// Whether the number of elements of a scalable vector is from the given
// `allowedLengths` list
class IsScalableVectorOfLengthPred<list<int> allowedLengths> :
And<[IsScalableVectorTypePred,
And<[IsVectorTypeWithAnyDimScalablePred,
Or<!foreach(allowedlength, allowedLengths,
CPred<[{::llvm::cast<::mlir::VectorType>($_self).getNumElements()
== }]
Expand Down