Add support for AttrSizedOperandSegments/AttrSizedResultSegments
authorLei Zhang <antiagainst@google.com>
Tue, 26 Nov 2019 01:26:16 +0000 (17:26 -0800)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Tue, 26 Nov 2019 01:26:50 +0000 (17:26 -0800)
commit13c6e419ca68cd4a5434f4349db5433395e6fbf0
tree3c880b0becb1e573af20fa3224abef75377d3d12
parent174076a1572047cf7945199ec5e7507d61f64e65
Add support for AttrSizedOperandSegments/AttrSizedResultSegments

Certain operations can have multiple variadic operands and their size
relationship is not always known statically. For such cases, we need
a per-op-instance specification to divide the operands into logical
groups or segments. This can be modeled by attributes.

This CL introduces C++ trait AttrSizedOperandSegments for operands and
AttrSizedResultSegments for results. The C++ trait just guarantees
such size attribute has the correct type (1D vector) and values
(non-negative), etc. It serves as the basis for ODS sugaring that
with ODS argument declarations we can further verify the number of
elements match the number of ODS-declared operands and we can generate
handy getter methods.

PiperOrigin-RevId: 282467075
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/TableGen/Operator.h
mlir/lib/IR/Operation.cpp
mlir/lib/TableGen/Operator.cpp
mlir/test/IR/traits.mlir
mlir/test/lib/TestDialect/TestOps.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/RewriterGen.cpp