llvm-project/mlir
Nicolas Vasilache c9d5f3418a Cleanup SuperVectorization dialect printing and parsing.
On the read side,
```
%3 = vector_transfer_read %arg0, %i2, %i1, %i0 {permutation_map: (d0, d1, d2)->(d2, d0)} : (memref<?x?x?xf32>, index, index, index) -> vector<32x256xf32>
```

becomes:

```
%3 = vector_transfer_read %arg0[%i2, %i1, %i0] {permutation_map: (d0, d1, d2)->(d2, d0)} : memref<?x?x?xf32>, vector<32x256xf32>
```

On the write side,

```
vector_transfer_write %0, %arg0, %c3, %c3 {permutation_map: (d0, d1)->(d0)} : vector<128xf32>, memref<?x?xf32>, index, index
```

becomes

```
vector_transfer_write %0, %arg0[%c3, %c3] {permutation_map: (d0, d1)->(d0)} : vector<128xf32>, memref<?x?xf32>
```

Documentation will be cleaned up in a followup commit that also extracts a proper .md from the top of the file comments.

PiperOrigin-RevId: 241021879
2019-03-29 17:56:42 -07:00
..
bindings/python Update header notices. 2019-03-29 17:43:20 -07:00
g3doc Cleanup SuperVectorization dialect printing and parsing. 2019-03-29 17:56:42 -07:00
include Cleanup SuperVectorization dialect printing and parsing. 2019-03-29 17:56:42 -07:00
lib Cleanup SuperVectorization dialect printing and parsing. 2019-03-29 17:56:42 -07:00
test Cleanup SuperVectorization dialect printing and parsing. 2019-03-29 17:56:42 -07:00
tools [TableGen] Support benefit score in pattern definition. 2019-03-29 17:55:55 -07:00
unittests Replace remaining usages of the Instruction class with Operation. 2019-03-29 17:50:04 -07:00
utils Update header notices. 2019-03-29 17:43:20 -07:00
.clang-format [mlir] add .clang-format 2019-03-29 12:41:43 -07:00
CONTRIBUTING.md Add contributing file. 2019-03-29 17:27:11 -07:00
LICENSE.TXT Continue sketching out basic infrastructure, including an input and output 2019-03-29 12:23:51 -07:00
README.md Fixed a few instances of inconsistent grammar. 2019-03-29 17:53:50 -07:00

README.md

Multi-Level Intermediate Representation Overview

The MLIR project aims to define a common intermediate representation (IR) that will unify the infrastructure required to execute high performance machine learning models in TensorFlow and similar ML frameworks. This project will include the application of HPC techniques, along with integration of search algorithms like reinforcement learning. This project aims to reduce the cost to bring up new hardware, and improve usability for existing TensorFlow users.

What is this doc?

Whereas the MLIR draft specification discusses the details of the IR in a dry style intended to be a long-lived reference document, this document discusses higher level issues. This includes:

  • How we see the IR being used
  • How the compiler will be implemented
  • What capabilities the IR enables

More resources

For more information on MLIR, please see:

or join the MLIR mailing list.

TODO: Replace with actual mailing list.

What is MLIR for?

MLIR is intended to be a hybrid IR which can support multiple different requirements in a unified infrastructure. For example, this includes:

  • The ability to represent all TensorFlow graphs, including dynamic shapes, the user-extensible op ecosystem, TensorFlow variables, etc.
  • Optimizations and transformations typically done on a TensorFlow graph, e.g. in Grappler.
  • Quantization and other graph transformations done on a TensorFlow graph or the TF Lite representation.
  • Representation of kernels for ML operations in a form suitable for optimization.
  • Ability to host high-performance-computing-style loop optimizations across kernels (fusion, loop interchange, tiling, etc), and transform memory layouts of data.
  • Code generation "lowering" transformations such as DMA insertion, explicit cache management, memory tiling, and vectorization for 1D and 2D register architectures.
  • Ability to represent target-specific operations, e.g. the MXU on TPUs.

MLIR is a common IR which also supports hardware specific operations. Thus, any investment into the infrastructure surrounding MLIR (e.g. the compiler passes that work on it) should yield good returns; many targets can use that infrastructure and will benefit from it.

MLIR is a powerful representation, but it also has non-goals. We do not try to support low level machine code generation algorithms (like register allocation and instruction scheduling). They are a better fit for lower level optimizers (such as LLVM). Also, we do not intend MLIR to be a source language that end-users would themselves write kernels in (analogous to CUDA C++). While we'd love to see a kernel language happen someday, that will be an independent project that compiles down to MLIR.

Compiler Infrastructure

We benefitted from the experience gained building HLO, LLVM and SIL when building MLIR. We will directly adopt existing best practices, e.g. writing and maintaining an IR spec, building an IR verifier, providing the ability to dump and parse MLIR files to text, writing extensive unit tests with the FileCheck tool, and building the infrastructure as a set of modular libraries that can be combined in new ways. We plan to use the infrastructure developed by the XLA team for performance analysis and benchmarking.

Other lessons have been incorporated and integrated into the design in subtle ways. For example, LLVM has non-obvious design mistakes that prevent a multithreaded compiler from working on multiple functions in an LLVM module at the same time. MLIR solves these problems by having per-function constant pools and by making references explicit with function_ref.

MLIR talks