OSDN Git Service

Reland "[mlir][linalg] Support parsing attributes in named op spec"
authorLei Zhang <antiagainst@google.com>
Mon, 11 Jan 2021 13:50:00 +0000 (08:50 -0500)
committerLei Zhang <antiagainst@google.com>
Tue, 12 Jan 2021 15:57:46 +0000 (10:57 -0500)
commit4086072f8a9200216088c435c9aa90a2d8ed74a5
tree94c68599e12df8aa4867a7056a6e1c1b8c9609e0
parent3f7b4ce96065eea66bf4344973173e76ec1a4255
Reland "[mlir][linalg] Support parsing attributes in named op spec"

With this, now we can specify a list of attributes on named ops
generated from the spec. The format is defined as

```
attr-id ::= bare-id (`?`)?
attr-typedef ::= type (`[` `]`)?
attr-def ::= attr-id `:` attr-typedef

tc-attr-def ::= `attr` `(` attr-def-list `)`
tc-def ::= `def` bare-id
  `(`tensor-def-list`)` `->` `(` tensor-def-list`)`
  (tc-attr-def)?
```

For example,

```
ods_def<SomeCppOp>
def some_op(...) -> (...)
attr(
  f32_attr: f32,
  i32_attr: i32,
  array_attr : f32[],
  optional_attr? : f32
)
```

where `?` means optional attribute and `[]` means array type.

Reviewed By: hanchung, nicolasvasilache

Differential Revision: https://reviews.llvm.org/D94240
mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp