Code Monkey home page Code Monkey logo

stablehlo's Introduction

StableHLO

StableHLO is an operation set for high-level operations (HLO) in machine learning (ML) models. Essentially, it's a portability layer between different ML frameworks and ML compilers: ML frameworks that produce StableHLO programs are compatible with ML compilers that consume StableHLO programs.

Our goal is to simplify and accelerate ML development by creating more interoperability between various ML frameworks (such as TensorFlow, JAX and PyTorch) and ML compilers (such as XLA and IREE).

StableHLO is based on the MHLO dialect and enhances it with additional functionality, including serialization and versioning. This provides backward and forward compatibility guarantees for StableHLO programs and ensures compatibility between frameworks and compilers, even as StableHLO continues to evolve.

This repository includes the StableHLO specification along with an MLIR-based implementation in C++ and Python, which you can use to define StableHLO programs for consumption by compilers such as XLA and IREE.

Build steps

Here's how to build the StableHLO repo:

  1. Make sure you have the LLVM-based linker lld installed:

    sudo apt update && sudo apt install lld
  2. Clone this repo and the LLVM git repository:

    git clone https://github.com/openxla/stablehlo
    cd stablehlo && git clone https://github.com/llvm/llvm-project.git
  3. Make sure you check out the correct commit in the LLVM repository:

    (cd llvm-project && git fetch && git checkout $(cat ../build_tools/llvm_version.txt))

    You need to do this every time llvm_version.txt changes.

  4. Configure and build MLIR:

    build_tools/build_mlir.sh ${PWD}/llvm-project/ ${PWD}/llvm-build

    This will take several minutes.

    Again, you need to do this every time llvm_version.txt changes.

  5. Build StableHLO as a standalone library:

    mkdir -p build && cd build
    
    cmake .. -GNinja \
      -DLLVM_ENABLE_LLD=ON \
      -DCMAKE_BUILD_TYPE=Release \
      -DLLVM_ENABLE_ASSERTIONS=On \
      -DMLIR_DIR=${PWD}/../llvm-build/lib/cmake/mlir
  6. Now you can make sure it works by running some tests:

    ninja check-stablehlo

    You should see results like this:

    Testing Time: 5.99s
      Passed: 47

    This runs all the tests in stablehlo/tests/.

Community

Building an amazing portability layer between ML frameworks and ML compilers requires collaboration across the whole ML industry, so we're happy to have your help on the StableHLO project.

We're using GitHub issues / pull requests to organize development and GitHub discussions to have longer discussions. We also have a #stablehlo channel on the OpenXLA Discord server.

stablehlo's People

Contributors

ashay avatar atondwal avatar bchetioui avatar d0k avatar ghpvnist avatar gleasonk avatar gnecula avatar scottamain avatar sdasgup3 avatar smit-hinsu avatar subhankarshah avatar tpopp avatar yaochengji 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.