-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[MLIR] Add support for IntArrayProp<I32Prop> #146685
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The conversion to attribute was missing.
|
@llvm/pr-subscribers-mlir Author: Mehdi Amini (joker-eph) ChangesThe conversion to attribute was missing. Full diff: https://github.com/llvm/llvm-project/pull/146685.diff 5 Files Affected:
diff --git a/mlir/include/mlir/IR/ODSSupport.h b/mlir/include/mlir/IR/ODSSupport.h
index b24a2470470ff..036ce4e5b725f 100644
--- a/mlir/include/mlir/IR/ODSSupport.h
+++ b/mlir/include/mlir/IR/ODSSupport.h
@@ -118,6 +118,9 @@ convertFromAttribute(SmallVectorImpl<int32_t> &storage, Attribute attr,
/// Convert the provided ArrayRef<int64_t> to a DenseI64ArrayAttr attribute.
Attribute convertToAttribute(MLIRContext *ctx, ArrayRef<int64_t> storage);
+/// Convert the provided ArrayRef<int32_t> to a DenseI32ArrayAttr attribute.
+Attribute convertToAttribute(MLIRContext *ctx, ArrayRef<int32_t> storage);
+
} // namespace mlir
#endif // MLIR_IR_ODSSUPPORT_H
diff --git a/mlir/lib/IR/ODSSupport.cpp b/mlir/lib/IR/ODSSupport.cpp
index 5b0a3e22139e1..69b4a563e6b75 100644
--- a/mlir/lib/IR/ODSSupport.cpp
+++ b/mlir/lib/IR/ODSSupport.cpp
@@ -173,3 +173,8 @@ Attribute mlir::convertToAttribute(MLIRContext *ctx,
ArrayRef<int64_t> storage) {
return DenseI64ArrayAttr::get(ctx, storage);
}
+
+Attribute mlir::convertToAttribute(MLIRContext *ctx,
+ ArrayRef<int32_t> storage) {
+ return DenseI32ArrayAttr::get(ctx, storage);
+}
diff --git a/mlir/test/IR/properties.mlir b/mlir/test/IR/properties.mlir
index dde9100cde142..b541447e85c7b 100644
--- a/mlir/test/IR/properties.mlir
+++ b/mlir/test/IR/properties.mlir
@@ -2,10 +2,10 @@
// # RUN: mlir-opt %s -mlir-print-op-generic -split-input-file | mlir-opt -mlir-print-op-generic | FileCheck %s --check-prefix=GENERIC
// CHECK: test.with_properties
-// CHECK-SAME: a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4]{{$}}
+// CHECK-SAME: a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4], array32 = [5, 6]{{$}}
// GENERIC: "test.with_properties"()
-// GENERIC-SAME: <{a = 32 : i64, array = array<i64: 1, 2, 3, 4>, b = "foo", c = "bar", flag = true}> : () -> ()
-test.with_properties a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4]
+// GENERIC-SAME: <{a = 32 : i64, array = array<i64: 1, 2, 3, 4>, array32 = array<i32: 5, 6>, b = "foo", c = "bar", flag = true}> : () -> ()
+test.with_properties a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4], array32 = [5, 6]
// CHECK: test.with_nice_properties
// CHECK-SAME: "foo bar" is -3{{$}}
diff --git a/mlir/test/Transforms/test-legalizer.mlir b/mlir/test/Transforms/test-legalizer.mlir
index 79518b04e7158..40ab3fc974cb4 100644
--- a/mlir/test/Transforms/test-legalizer.mlir
+++ b/mlir/test/Transforms/test-legalizer.mlir
@@ -434,7 +434,7 @@ func.func @test_properties_rollback() {
// CHECK: test.with_properties a = 32,
// expected-remark @below{{op 'test.with_properties' is not legalizable}}
test.with_properties
- a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4]
+ a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4], array32 = [5, 6]
{modify_inplace}
"test.return"() : () -> ()
}
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index 0ad5bfa9a58ab..97469d29ec961 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -3179,13 +3179,15 @@ def TestOpWithProperties : TEST_Op<"with_properties"> {
`b` `=` $b `,`
`c` `=` $c `,`
`flag` `=` $flag `,`
- `array` `=` $array attr-dict}];
+ `array` `=` $array `,`
+ `array32` `=` $array32 attr-dict}];
let arguments = (ins
I64Prop:$a,
StrAttr:$b, // Attributes can directly be used here.
StringProp:$c,
BoolProp:$flag,
- IntArrayProp<I64Prop>:$array // example of an array
+ IntArrayProp<I64Prop>:$array, // example of an array
+ IntArrayProp<I32Prop>:$array32 // example of an array
);
}
|
|
@llvm/pr-subscribers-mlir-core Author: Mehdi Amini (joker-eph) ChangesThe conversion to attribute was missing. Full diff: https://github.com/llvm/llvm-project/pull/146685.diff 5 Files Affected:
diff --git a/mlir/include/mlir/IR/ODSSupport.h b/mlir/include/mlir/IR/ODSSupport.h
index b24a2470470ff..036ce4e5b725f 100644
--- a/mlir/include/mlir/IR/ODSSupport.h
+++ b/mlir/include/mlir/IR/ODSSupport.h
@@ -118,6 +118,9 @@ convertFromAttribute(SmallVectorImpl<int32_t> &storage, Attribute attr,
/// Convert the provided ArrayRef<int64_t> to a DenseI64ArrayAttr attribute.
Attribute convertToAttribute(MLIRContext *ctx, ArrayRef<int64_t> storage);
+/// Convert the provided ArrayRef<int32_t> to a DenseI32ArrayAttr attribute.
+Attribute convertToAttribute(MLIRContext *ctx, ArrayRef<int32_t> storage);
+
} // namespace mlir
#endif // MLIR_IR_ODSSUPPORT_H
diff --git a/mlir/lib/IR/ODSSupport.cpp b/mlir/lib/IR/ODSSupport.cpp
index 5b0a3e22139e1..69b4a563e6b75 100644
--- a/mlir/lib/IR/ODSSupport.cpp
+++ b/mlir/lib/IR/ODSSupport.cpp
@@ -173,3 +173,8 @@ Attribute mlir::convertToAttribute(MLIRContext *ctx,
ArrayRef<int64_t> storage) {
return DenseI64ArrayAttr::get(ctx, storage);
}
+
+Attribute mlir::convertToAttribute(MLIRContext *ctx,
+ ArrayRef<int32_t> storage) {
+ return DenseI32ArrayAttr::get(ctx, storage);
+}
diff --git a/mlir/test/IR/properties.mlir b/mlir/test/IR/properties.mlir
index dde9100cde142..b541447e85c7b 100644
--- a/mlir/test/IR/properties.mlir
+++ b/mlir/test/IR/properties.mlir
@@ -2,10 +2,10 @@
// # RUN: mlir-opt %s -mlir-print-op-generic -split-input-file | mlir-opt -mlir-print-op-generic | FileCheck %s --check-prefix=GENERIC
// CHECK: test.with_properties
-// CHECK-SAME: a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4]{{$}}
+// CHECK-SAME: a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4], array32 = [5, 6]{{$}}
// GENERIC: "test.with_properties"()
-// GENERIC-SAME: <{a = 32 : i64, array = array<i64: 1, 2, 3, 4>, b = "foo", c = "bar", flag = true}> : () -> ()
-test.with_properties a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4]
+// GENERIC-SAME: <{a = 32 : i64, array = array<i64: 1, 2, 3, 4>, array32 = array<i32: 5, 6>, b = "foo", c = "bar", flag = true}> : () -> ()
+test.with_properties a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4], array32 = [5, 6]
// CHECK: test.with_nice_properties
// CHECK-SAME: "foo bar" is -3{{$}}
diff --git a/mlir/test/Transforms/test-legalizer.mlir b/mlir/test/Transforms/test-legalizer.mlir
index 79518b04e7158..40ab3fc974cb4 100644
--- a/mlir/test/Transforms/test-legalizer.mlir
+++ b/mlir/test/Transforms/test-legalizer.mlir
@@ -434,7 +434,7 @@ func.func @test_properties_rollback() {
// CHECK: test.with_properties a = 32,
// expected-remark @below{{op 'test.with_properties' is not legalizable}}
test.with_properties
- a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4]
+ a = 32, b = "foo", c = "bar", flag = true, array = [1, 2, 3, 4], array32 = [5, 6]
{modify_inplace}
"test.return"() : () -> ()
}
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index 0ad5bfa9a58ab..97469d29ec961 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -3179,13 +3179,15 @@ def TestOpWithProperties : TEST_Op<"with_properties"> {
`b` `=` $b `,`
`c` `=` $c `,`
`flag` `=` $flag `,`
- `array` `=` $array attr-dict}];
+ `array` `=` $array `,`
+ `array32` `=` $array32 attr-dict}];
let arguments = (ins
I64Prop:$a,
StrAttr:$b, // Attributes can directly be used here.
StringProp:$c,
BoolProp:$flag,
- IntArrayProp<I64Prop>:$array // example of an array
+ IntArrayProp<I64Prop>:$array, // example of an array
+ IntArrayProp<I32Prop>:$array32 // example of an array
);
}
|
ftynse
approved these changes
Jul 5, 2025
Co-authored-by: Oleksandr "Alex" Zinenko <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The conversion to attribute was missing.