intel / graph-compiler

Apache License 2.0
13 stars 13 forks source link

Graph Compiler

Graph Compiler is an end-to-end, MLIR-based compiler designed to enhance the performance of deep learning workloads. It accepts computation graphs from the frontend, applies domain-specific optimizations and transformations, generates code, and manages runtime execution.

The current frontend for Graph Compiler is oneDNN Graph API.

Build instructions

All-in-one compile script

It is recommended for the users to use the all-in-one compile script at scripts/compile.sh. It downloads the LLVM dependency and builds the project.

Step-by-step build intructions

To build this project step by step, first you need to find the LLVM commit-id we are using at cmake/llvm-version.txt. Then clone specific version of LLVM:

export LLVM_COMMIT_HASH=$(< cmake/llvm-version.txt)
git clone https://github.com/llvm/llvm-project
cd llvm-project
git checkout $LLVM_COMMIT_HASH

Build LLVM with the command lines given in .github/workflows/build-llvm.yml:

mkdir llvm-install
cmake -G Ninja llvm -B build -DCMAKE_INSTALL_PREFIX=llvm-install \
  -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=true -DLLVM_ENABLE_PROJECTS="mlir" -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_INSTALL_UTILS=true -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DLLVM_INSTALL_GTEST=ON
cmake --build build --target install

Notes

We have now installed LLVM at llvm-project/llvm-install.

Change working directory to graph-compiler repo and prepare the build directory:

cd /PATH/TO/graph-compiler
mkdir build && cd build

Build and run tests:

cmake .. -G Ninja \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DMLIR_DIR=/PATH/TO/llvm-project/llvm-install/lib/cmake/mlir \
    -DLLVM_EXTERNAL_LIT=$(which lit)
cmake --build . --target gc-check

Notes:

Graph Compiler supports the following build-time options.

CMake Option Supported values (defaults in bold) Description
GC_LEGACY_ENABLE ON, OFF Controls building the legacy graph-compiler component
GC_TEST_ENABLE ON, OFF Controls building the tests
GC_DEV_LINK_LLVM_DYLIB ON, OFF Controls dynamic link LLVM/MLIR libraries, mainly for developer
GC_ENABLE_BINDINGS_PYTHON ON, OFF Controls building the Python API