diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -180,6 +180,10 @@ shape of type. This is mostly used for convenience interface generation or interaction with other frameworks/translation. + All derived attributes should be materializable as an Attribute. That is, + even though they are not materialized, it should be possible to store as + an attribute. + Both operands and attributes are specified inside the `dag`-typed `arguments`, led by `ins`: diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1386,6 +1386,9 @@ // DerivedAttr are attributes whose value is computed from properties // of the operation. They do not require additional storage and are // materialized as needed. +// Note: All derived attributes should be materializable as an Attribute. E.g., +// do not used DerivedAttr for things that could not have been stored as +// Attribute. class DerivedAttr : Attr, "derived attribute"> { let returnType = ret; code body = b;