GithubHelp home page GithubHelp logo

hhy5277 / mlir Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tensorflow/mlir

0.0 1.0 0.0 5.09 MB

"Multi-Level Intermediate Representation" Compiler Infrastructure

License: Apache License 2.0

CMake 0.48% C++ 98.26% Python 0.88% CSS 0.01% C 0.20% Emacs Lisp 0.11% Vim Script 0.07%

mlir's Introduction

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.

Note that this repository contains the core of the MLIR framework. The TensorFlow compilers we are building on top of MLIR will be part of the main TensorFlow repository soon.

More resources

For more information on MLIR, please see:

Join the MLIR mailing list to hear about announcements and discussions. Please be mindful of the TensorFlow Code of Conduct, which pledges to foster an open and welcoming environment.

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 to 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 that 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 would love to see a kernel language happen someday, that will be an independent project that compiles down to MLIR.

Compiler infrastructure

We benefitted from experience gained from building other IRs (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.

Getting started with MLIR

MLIR has been tested on Linux and macOS, with recent versions of clang and with gcc 7.

git clone https://github.com/llvm/llvm-project.git
cd llvm-project/llvm/projects/
git clone https://github.com/tensorflow/mlir
cd ../..
mkdir build
cd build
cmake -G Ninja ../llvm -DLLVM_BUILD_EXAMPLES=ON
ninja check-mlir

As a starter, you may try the tutorial on building a compiler for a Toy language.

MLIR talks

mlir's People

Contributors

andydavis1 avatar antiagainst avatar benvanik avatar brianwa84 avatar dan-zheng avatar dimitriv avatar ftynse avatar gmngeoffrey avatar joker-eph avatar jpienaar avatar lattner avatar liufengdb avatar river707 avatar rsuderman avatar smit-hinsu avatar superbobry avatar tatianashp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.