[Mlir-commits] [mlir] e83c6aa - [MLIR] [LangRef] Clarify parsing of dense<...>
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Mar 16 09:57:31 PDT 2022
Author: Siddharth Bhat
Date: 2022-03-16T22:25:52+05:30
New Revision: e83c6aa91e0e336468c00b0fc2d424c889223e1f
URL: https://github.com/llvm/llvm-project/commit/e83c6aa91e0e336468c00b0fc2d424c889223e1f
DIFF: https://github.com/llvm/llvm-project/commit/e83c6aa91e0e336468c00b0fc2d424c889223e1f.diff
LOG: [MLIR] [LangRef] Clarify parsing of dense<...>
dense<...> expects ... to be a tensor-literal.
Define this in the grammar in BuiltinAttributes.td,
and reflect this in the reference grammar written in
AttributeParser.cpp.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D121048
Added:
Modified:
mlir/include/mlir/IR/BuiltinAttributes.td
mlir/lib/Parser/AttributeParser.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td
index 13ef16b42b695..74cba43e1c43a 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.td
+++ b/mlir/include/mlir/IR/BuiltinAttributes.td
@@ -153,7 +153,8 @@ def Builtin_DenseIntOrFPElementsAttr : Builtin_Attr<
Syntax:
```
- dense-intorfloat-elements-attribute ::= `dense` `<` attribute-value `>` `:`
+ tensor-literal ::= integer-literal | float-literal | [] | [tensor-literal (, tensor-literal)* ]
+ dense-intorfloat-elements-attribute ::= `dense` `<` tensor-literal `>` `:`
( tensor-type | vector-type )
```
diff --git a/mlir/lib/Parser/AttributeParser.cpp b/mlir/lib/Parser/AttributeParser.cpp
index 8e6e9d25f8237..15d8b17fbdf3c 100644
--- a/mlir/lib/Parser/AttributeParser.cpp
+++ b/mlir/lib/Parser/AttributeParser.cpp
@@ -33,7 +33,7 @@ using namespace mlir::detail;
/// | `[` (attribute-value (`,` attribute-value)*)? `]`
/// | `{` (attribute-entry (`,` attribute-entry)*)? `}`
/// | symbol-ref-id (`::` symbol-ref-id)*
-/// | `dense` `<` attribute-value `>` `:`
+/// | `dense` `<` tensor-literal `>` `:`
/// (tensor-type | vector-type)
/// | `sparse` `<` attribute-value `,` attribute-value `>`
/// `:` (tensor-type | vector-type)
More information about the Mlir-commits
mailing list