[Mlir-commits] [mlir] [MLIR Attr] add ArrayMaxCount attribute constraint (PR #92453)
Ryan Thomas Lynch
llvmlistbot at llvm.org
Thu May 16 15:13:25 PDT 2024
https://github.com/emosy updated https://github.com/llvm/llvm-project/pull/92453
>From 77d307fafae9d36983c5b71bd955b83e67104484 Mon Sep 17 00:00:00 2001
From: Ryan Thomas Lynch <rlynch34 at gatech.edu>
Date: Thu, 16 May 2024 20:54:09 +0000
Subject: [PATCH 1/2] [MLIR Attr] add ArrayMaxCount
this is the dual of ArrayMinCount. I saw that I needed it but it didn't exist yet
---
mlir/include/mlir/IR/CommonAttrConstraints.td | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mlir/include/mlir/IR/CommonAttrConstraints.td b/mlir/include/mlir/IR/CommonAttrConstraints.td
index 0d69bb0717a59..d99bde1f87ef0 100644
--- a/mlir/include/mlir/IR/CommonAttrConstraints.td
+++ b/mlir/include/mlir/IR/CommonAttrConstraints.td
@@ -773,6 +773,10 @@ def IntPositive : AttrConstraint<
CPred<"::llvm::cast<::mlir::IntegerAttr>($_self).getValue().isStrictlyPositive()">,
"whose value is positive">;
+class ArrayMaxCount<int n> : AttrConstraint<
+ CPred<"::llvm::cast<::mlir::ArrayAttr>($_self).size() <= " # n>,
+ "with at most " # n # " elements">;
+
class ArrayMinCount<int n> : AttrConstraint<
CPred<"::llvm::cast<::mlir::ArrayAttr>($_self).size() >= " # n>,
"with at least " # n # " elements">;
>From 8d971794d31efbe6278ff950440b20bd3c76cdb1 Mon Sep 17 00:00:00 2001
From: Ryan Thomas Lynch <rlynch34 at gatech.edu>
Date: Thu, 16 May 2024 22:12:47 +0000
Subject: [PATCH 2/2] [MLIR/NFC] Operations.md: Explain all primitive
constraints
---
mlir/docs/DefiningDialects/Operations.md | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/mlir/docs/DefiningDialects/Operations.md b/mlir/docs/DefiningDialects/Operations.md
index 706abce55ce96..beb9988c18ae7 100644
--- a/mlir/docs/DefiningDialects/Operations.md
+++ b/mlir/docs/DefiningDialects/Operations.md
@@ -291,8 +291,27 @@ Right now, the following primitive constraints are supported:
equal to `N`
* `IntMaxValue<N>`: Specifying an integer attribute to be less than or equal
to `N`
+* `IntNEQValue<N>`: Specifying an integer attribute to be not equal
+ to `N`
+* `IntPositive`: Specifying an integer attribute whose value is positive
+* `IntNonNegative`: Specifying an integer attribute whose value is
+ non-negative
* `ArrayMinCount<N>`: Specifying an array attribute to have at least `N`
elements
+* `ArrayMaxCount<N>`: Specifying an array attribute to have at most `N`
+ elements
+* `ArrayCount<N>`: Specifying an array attribute to have exactly `N`
+ elements
+* `DenseArrayCount<N>`: Specifying a dense array attribute to have
+ exactly `N` elements
+* `DenseArrayStrictlyPositive<arrayType>`: Specifying a dense array attribute
+ of type `arrayType` to have all positive elements
+* `DenseArrayStrictlyNonNegative<arrayType>`: Specifying a dense array attribute
+ of type `arrayType` to have all non-negative elements
+* `DenseArraySorted<arrayType>`: Specifying a dense array attribute
+ of type `arrayType` to have elements in non-decreasing order
+* `DenseArrayStrictlySorted<arrayType>`: Specifying a dense array attribute
+ of type `arrayType` to have elements in increasing order
* `IntArrayNthElemEq<I, N>`: Specifying an integer array attribute's `I`-th
element to be equal to `N`
* `IntArrayNthElemMinValue<I, N>`: Specifying an integer array attribute's
@@ -301,6 +320,7 @@ Right now, the following primitive constraints are supported:
`I`-th element to be less than or equal to `N`
* `IntArrayNthElemInRange<I, M, N>`: Specifying an integer array attribute's
`I`-th element to be greater than or equal to `M` and less than or equal to `N`
+* `IsNullAttr`: Specifying an optional attribute which must be empty
TODO: Design and implement more primitive constraints
More information about the Mlir-commits
mailing list