Skip to content

Repository files navigation

About this repo

Since stableHLO Release does not provide prebuilt binaries, you need to build StableHLO yourself in order to use stablehlo-opt. Therefore, a prebuilt binary is uploaded here in advance. As you can see below, please note that this is a minimal version that only supports basic functionality.

How to Use

Clone this repository into a directory named build under your stablehlo directory, as shown in the image below.

cd /path/to/stablehlo
sudo apt update
sudo apt install -y git-lfs
git lfs install
git clone https://github.com/joon363/StableHLO-compiler-pre-built-binary.git build

directory

Now you can use stablehlo-opt!

How to reproduce this folder

1. Clone repos

StableHLO 1.0 Source Code

cd /workspace
git clone --depth=1 --single-branch https://github.com/openxla/stablehlo

llvm-project 22.1.0 Binary

wget https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.0-rc1/LLVM-22.1.0-rc1-Linux-X64.tar.xz

tar -xJf LLVM-22.1.0-rc1-Linux-X64.tar.xz

2. StableHLO Build

Modify CMakeLists.txt

  • The downloaded LLVM binary does not include FileCheck and not. These binaries are only generated when building llvm-project directly with -D LLVM_INSTALL_UTILS=ON.
  • However, these tools are used only for the test suite, so they are not required for development.
  • If you have an environment where you can build LLVM yourself, you can skip this step. In my case, the build took more than 4 hours, so I abandoned it.

/workspace/stablehlo/stablehlo/CMakeLists.txt

# add_subdirectory(api)
add_subdirectory(conversions)
add_subdirectory(dialect)
# add_subdirectory(integrations)
add_subdirectory(reference)
add_subdirectory(tests)
# add_subdirectory(testdata)
add_subdirectory(tools)
add_subdirectory(transforms)

/workspace/stablehlo/stablehlo/conversions/linalg/CMakeLists.txt

# add_subdirectory(tests)

/workspace/stablehlo/stablehlo/conversions/tosa/CMakeLists.txt

# add_subdirectory(tests)

/workspace/stablehlo/stablehlo/tools/CMakeLists.txt

# add_dependencies(check-stablehlo-quick stablehlo-lsp-server)

/workspace/stablehlo/stablehlo/tests/CMakeLists.txt

# add_lit_testsuite(check-stablehlo-tests "Running the tests/ suite"
#   ${CMAKE_CURRENT_BINARY_DIR}
#   DEPENDS
#   FileCheck not
#   stablehlo-opt
#   stablehlo-translate
# )
# add_dependencies(check-stablehlo-quick check-stablehlo-tests)

Build

rm -rf build

mkdir -p build

cd build

cmake .. -GNinja   -DLLVM_ENABLE_LLD="$LLVM_ENABLE_LLD" -DCMAKE_BUILD_TYPE='Release'   -DLLVM_ENABLE_ASSERTIONS='ON' -DSTABLEHLO_ENABLE_BINDINGS_PYTHON='OFF' -DMLIR_DIR=/LLVM-22.1.0-rc1-Linux-X64/lib/cmake/mlir # Path where the LLVM binary was extracted earlier

ninja -j 8 # Set to the desired number of jobs

About

Pre-built stableHLO Compiler Binary Files (stablehlo-opt, stablehlo-translate, stablehlo-lsp-server)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages