The ByteIR Compiler is an MLIR-based compiler for CPU/GPU/ASIC.
LLVM/MLIR: https://github.com/llvm/llvm-project, llvm commit id see external/llvm-project
.
Python (for python binding): minimum version is 3.6, requiring numpy and pybind11 installed.
Make sure to apply possible patches for submodules
bash /path_to_byteir/scripts/apply_patches.sh
mkdir /path_to_byteir/build
cd /path_to_byteir/build/
# build ByteIR
cmake ../cmake/ -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_INSTALL_PATH=path_to_LLVM_installed_or_built_directory \
-DLLVM_EXTERNAL_LIT=lit_executatble_location # or using $(which lit), this is optional for external lit
cmake --build . --target all
mkdir /path_to_byteir/build
cd /path_to_byteir/build/
# build ByteIR
cmake ../cmake/ -G "Visual Studio 16 2019" -A x64 \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_INSTALL_PATH=path_to_LLVM_installed_or_built_directory \
-DLLVM_EXTERNAL_LIT=lit_location # this is optional for external lit
cmake --build . --target all
This command runs all ByteIR unit tests:
cmake --build . --target check-byteir
ByteIR relies on llvm-lit
and FileCheck
for testing.
For more information, you can refer to this page
All the tests are placed in the folder byteir/test
.
cmake --install . --prefix path_to_install_BYTEIR
cmake --build . --target byteir-python-pack
# byteir-*.whl in /path_to_byteir/build/python/dist/
ByteIR Compiler mainly relies on MLIR public, builtin dialects. However, there are still some exceptions.
An external dialect from https://github.com/tensorflow/mlir-hlo. MHLO is the main dialect ByteIR compiler takes as the input IR.
There are several MHLO custom_call Ops used in ByteIR. They are used in a contract between ByteIR compiler and ByteIR maintained frontends. They are listed in doc/byteir_mhlo_custom_call.md
ACE is an internal dialect defined by ByteIR. It is a supplement to MHLO dialect and LACE is the corresponding part of LMHLO.
LinalgExt is a dialect defined by ByteIR. It is an extension of Linalg dialect, and it is meant to eventually be upstreamed to LLVM.
ShapeExt is a dialect defined by ByteIR. It is an extension of Shape dialect, and it is meant to eventually be upstreamed to LLVM.
ByRE is a dialect defined by ByteIR. It is a runtime IR and the major format for the ByteIR runtime.
Useful Pass Description doc/passes.md