[Mlir-commits] [mlir] 57ce79f - [mlir] Clarify constraint on derived attribute

Jacques Pienaar llvmlistbot at llvm.org
Tue Mar 24 13:01:12 PDT 2020


Author: Jacques Pienaar
Date: 2020-03-24T13:00:48-07:00
New Revision: 57ce79f74d27915249a669d40cf04ed27aedf602

URL: https://github.com/llvm/llvm-project/commit/57ce79f74d27915249a669d40cf04ed27aedf602
DIFF: https://github.com/llvm/llvm-project/commit/57ce79f74d27915249a669d40cf04ed27aedf602.diff

LOG: [mlir] Clarify constraint on derived attribute

Summary:
The restriction that a derived attribute should represent an
attribute/be materializable as an attribute was not made clear.

Differential Revision: https://reviews.llvm.org/D76715

Added: 
    

Modified: 
    mlir/docs/OpDefinitions.md
    mlir/include/mlir/IR/OpBase.td

Removed: 
    


################################################################################
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<code ret, code b> : Attr<CPred<"true">, "derived attribute"> {
   let returnType = ret;
   code body = b;


        


More information about the Mlir-commits mailing list