Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

MLIR

< >

MLIR, aka Multi-Level Intermediate Representation, is an intermediate representation language created in 2019 by Chris Lattner.

#230on PLDB 6Years Old 84Repos
Download source code:
git clone https://github.com/tensorflow/mlir
Homepage · Source Code

The MLIR project is a novel approach to building reusable and extensible compiler infrastructure. MLIR aims to address software fragmentation, improve compilation for heterogeneous hardware, significantly reduce the cost of building domain specific compilers, and aid in connecting existing compilers together.


Example from the web:
// Syntactically similar to LLVM: func @testFunction(%arg0: i32) { %x = call @thingToCall(%arg0) : (i32) -> i32 br ^bb1 ^bb1: %y = addi %x, %x : i32 return %y : i32 }
Example from Compiler Explorer:
// Example code of an affine reduction. // MLIR example code may not always work out of the box because the textual MLIR format is not stable. // The example tries to be compatible with the latest MLIR version, which may not work on previous versions. func @affine_parallel_with_reductions_i64(%arg0: memref<3x3xi64>, %arg1: memref<3x3xi64>) -> (i64, i64) { %0:2 = affine.parallel (%kx, %ky) = (0, 0) to (2, 2) reduce ("addi", "muli") -> (i64, i64) { %1 = affine.load %arg0[%kx, %ky] : memref<3x3xi64> %2 = affine.load %arg1[%kx, %ky] : memref<3x3xi64> %3 = arith.muli %1, %2 : i64 %4 = arith.addi %1, %2 : i64 affine.yield %3, %4 : i64, i64 } return %0#0, %0#1 : i64, i64 }

Language features

Feature Supported Example Token
Comments ✓ // A comment
Line Comments ✓ // A comment //
Semantic Indentation X

- Build the next great programming language · Add · Add Prompt · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v170.1.0