Multi-Level Intermediate Representation (MLIR)

•MLIR : Multi-Level Intermediate Representation

•Model -> MLIR -> Hardware Specific Code

•MLIR is:

•A representation format for Intermediate Representation (IR)

•A library of compiler utilities.

•It sits between the model representation and low-level compilers that generate hardware-specific code.

•Abstraction for Global Compiler Infrastructure

•MLIR provides the infrastructure for high level compilation

•It supports gradual lowering to low level representations via customizable dialects

•LLVM IR is supported as a lower level dialect which provides integration with LLVM execution environment.

•MLIR contains tools for creation of custom dialects and for inter-dialect transformation.

•MLIR does not specify any fixed instruction set unlike most IR representations.

•In the Machine Learning Domain there has been a proliferation of input formats:

  • TensorFlow graphs (Google)
  • XLA IR / HLO (Google)
  • Onnx (Facebook, Microsoft)
  • Glow (Facebook)
  • nGraph (Intel)
  • Stripe (PlaidML, now Intel)
  • Halide IR, TVM (universities)

•MLIR consists of several dialects:

  • TensorFlow IR
  • XLA HLO IR
  • Affine dialect ( polyhedral representation )
  • LLVM IR
  • Tensorflow Lite
  • GPU dialects
  • Vector dialect
  • Custom defined IRs …

•MLIR also includes GPU dialect to target

  • CUDA,
  • RocM, and
  • SPIR-V/Vulkan

•Conversion from one dialect to another can be performed using mlir-opt tool

For example,

mlir-opt -convert-spirv-to-llvm <filename.mlir>

•A MLIR dialect includes:

● A prefix (“namespace”)

● A list of custom types, each its C++ class.

● A list of operations, each its name and C++ class implementation:

  • Verifier for operation invariants
  • Semantics (has-no-side-effects, constant-folding etc.)

● Possibly custom parser and assembly printer

● Passes: analysis, transformations, and dialect conversions.

•MLIR does not provide an instruction set

•In MLIR everything is about operations

Example:

func @some_func(%arg0: !my_dialect<"custom_type">)

 -> !another_dialect<"other_type"> {

       %result = "custom.operation"(%arg0)

 : (!my_dialect<"custom_type">) ->       

            !another_dialect<"other_type">

       return %result : !another_dialect<"other_type">

}

To view or add a comment, sign in

More articles by Prateek Khanna

  • Factors governing human behaviour

    Human behaviour is like an iceberg. We tend to perceive only the way a person responds in a given context, but we…

  • White Hydrogen

    White hydrogen is a naturally occurring, geological hydrogen found in underground deposits. White hydrogen is believed…

  • Chandrayaan 3 landing stages

    Chandrayaan 3 Lander Module (Vikram Lander) is orbiting the moon at 25 km * 134 km. It is expected to commence descent…

  • Smoothening mechanisms in Language Models

    Language Model A language model is a computational model or statistical framework that aims to capture and represent…

  • Union Budget 2022 and India’s Startup Ecosystem

    India has the third-largest number of startups in the world after the United States and China. The Indian startup…

  • Hydrogen economy

    Fossil fuels represents a significant import item for most major developing economies including India. India’s energy…

  • Cooperative & Competitive Strategy

    Strategy of a firm involves the following objectives- creating value, handling imitation and shaping its perimeter…

  • Drone Rules 2021

    Draft Drone Rules 2021 released on 15 July 2021 are proposed to supersede the Unmanned Aircraft System Rules 2021…

  • LLVM-IR

    •LLVM is a compiler infrastructure •It is implemented as a set of reusable libraries •Implemented in C++ •Originally…

  • Low Cost COVID19 Detection - COVIRAP

    Overview: •Covid-19 detection device •Built by IIT Kharagpur •Cuboid shaped box + Kit •Delivers test results in an hour…

Insights from the community

Others also viewed

Explore topics