Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions mlir/include/mlir/IR/ODSSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions mlir/lib/IR/ODSSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
6 changes: 3 additions & 3 deletions mlir/test/IR/properties.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -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{{$}}
Expand Down
2 changes: 1 addition & 1 deletion mlir/test/Transforms/test-legalizer.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -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"() : () -> ()
}
Expand Down
6 changes: 4 additions & 2 deletions mlir/test/lib/Dialect/Test/TestOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
Loading