llvm-project/mlir
River Riddle d80d3a358f [mlir] Refactor ElementsAttr into an AttrInterface
This revision refactors ElementsAttr into an Attribute Interface.
This enables a common interface with which to interact with
element attributes, without needing to modify the builtin
dialect. It also removes a majority (if not all?) of the need for
the current OpaqueElementsAttr, which was originally intended as
a way to opaquely represent data that was not representable by
the other builtin constructs.

The new ElementsAttr interface not only allows for users to
natively represent their data in the way that best suits them,
it also allows for efficient opaque access and iteration of the
underlying data. Attributes using the ElementsAttr interface
can directly expose support for interacting with the held
elements using any C++ data type they claim to support. For
example, DenseIntOrFpElementsAttr supports iteration using
various native C++ integer/float data types, as well as
APInt/APFloat, and more. ElementsAttr instances that refer to
DenseIntOrFpElementsAttr can use all of these data types for
iteration:

```c++
DenseIntOrFpElementsAttr intElementsAttr = ...;

ElementsAttr attr = intElementsAttr;
for (uint64_t value : attr.getValues<uint64_t>())
  ...;
for (APInt value : attr.getValues<APInt>())
  ...;
for (IntegerAttr value : attr.getValues<IntegerAttr>())
  ...;
```

ElementsAttr also supports failable range/iterator access,
allowing for selective code paths depending on data type
support:

```c++
ElementsAttr attr = ...;
if (auto range = attr.tryGetValues<uint64_t>()) {
  for (uint64_t value : *range)
    ...;
}
```

Differential Revision: https://reviews.llvm.org/D109190
2021-09-21 01:57:43 +00:00
..
cmake/modules [mlir][python] Simplify python extension loading. 2021-09-03 00:43:28 +00:00
docs [mlir] Update docs on conversion and translation to LLVM 2021-09-15 09:50:21 +02:00
examples [mlir] Add value_begin/value_end methods to DenseElementsAttr 2021-09-21 01:57:43 +00:00
include [mlir] Refactor ElementsAttr into an AttrInterface 2021-09-21 01:57:43 +00:00
lib [mlir] Refactor ElementsAttr into an AttrInterface 2021-09-21 01:57:43 +00:00
python [mlir][Linalg] Add ConvolutionOpInterface. 2021-09-20 10:41:10 -07:00
test [mlir] Refactor ElementsAttr into an AttrInterface 2021-09-21 01:57:43 +00:00
tools [mlir] Refactor ElementsAttr into an AttrInterface 2021-09-21 01:57:43 +00:00
unittests [mlir] Add value_begin/value_end methods to DenseElementsAttr 2021-09-21 01:57:43 +00:00
utils Update MLIR generate-test-checks.py to add the notice from the source into the generated file 2021-09-20 23:19:40 +00:00
.clang-format
.clang-tidy NFC: .clang-tidy: Inherit configs from parents to improve maintainability 2021-06-08 08:25:59 -07:00
CMakeLists.txt [MLIR] Drop old cmake var names 2021-05-24 15:30:01 +05:30
LICENSE.TXT
README.md

README.md

Multi-Level Intermediate Representation

See https://mlir.llvm.org/ for more information.