diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md index 4757dfcf3390..29269e508bb0 100644 --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -180,6 +180,10 @@ values, including two categories: 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 index d76c9d5476ef..845fa93878a1 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1386,6 +1386,9 @@ def SymbolRefArrayAttr : // 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 use DerivedAttr for things that could not have been stored as +// Attribute. class DerivedAttr : Attr, "derived attribute"> { let returnType = ret; code body = b;