|
1 | 1 | # Graph Compiler
|
2 |
| -Graph Compiler is in active development stage. |
| 2 | +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. |
| 3 | + |
| 4 | +The current frontend for Graph Compiler is [oneDNN Graph API](https://oneapi-src.github.io/oneDNN/graph_extension.html). |
| 5 | + |
| 6 | +## Build instructions |
| 7 | + |
| 8 | +### All-in-one compile script |
| 9 | + |
| 10 | +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. |
| 11 | + |
| 12 | +### Step-by-step build intructions |
| 13 | + |
| 14 | +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: |
| 15 | + |
| 16 | +```bash |
| 17 | +export LLVM_COMMIT_HASH=$(< cmake/llvm-version.txt) |
| 18 | +git clone https://github.com/llvm/llvm-project |
| 19 | +cd llvm-project |
| 20 | +git checkout $LLVM_COMMIT_HASH |
| 21 | +``` |
| 22 | + |
| 23 | +Build LLVM with the command lines given in `.github/workflows/build-llvm.yml`: |
| 24 | + |
| 25 | +```bash |
| 26 | +mkdir llvm-install |
| 27 | +cmake -G Ninja llvm -B build -DCMAKE_INSTALL_PREFIX=llvm-install \ |
| 28 | + -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 |
| 29 | +cmake --build build --target install |
| 30 | +``` |
| 31 | + |
| 32 | +Notes |
| 33 | + * It is recommended to add optional options `-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON` to the command `cmake -G Ninja llvm ...` above. These will enable the build of LLVM/MLIR dynamic libraries and let MLIR/LLVM tools link to them, to reduce the installed binary size of LLVM/MLIR. These options also enable the `GC_DEV_LINK_LLVM_DYLIB` option of graph-compiler repo (see below). |
| 34 | + * The option `-DLLVM_INSTALL_GTEST=ON` is optional, if the tests of graph-compiler are disabled (see `GC_TEST_ENABLE` below). |
| 35 | + |
| 36 | +We have now installed LLVM at `llvm-project/llvm-install`. |
| 37 | + |
| 38 | +Change working directory to graph-compiler repo and prepare the build directory: |
| 39 | + |
| 40 | +```bash |
| 41 | +cd /PATH/TO/graph-compiler |
| 42 | +mkdir build && cd build |
| 43 | +``` |
| 44 | + |
| 45 | +Build and run tests: |
| 46 | + |
| 47 | +```bash |
| 48 | +cmake .. -G Ninja \ |
| 49 | + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ |
| 50 | + -DMLIR_DIR=/PATH/TO/llvm-project/llvm-install/lib/cmake/mlir \ |
| 51 | + -DLLVM_EXTERNAL_LIT=$(which lit) |
| 52 | +cmake --build . --target gc-check |
| 53 | +``` |
| 54 | + |
| 55 | +Notes: |
| 56 | + * `/PATH/TO/llvm-project/llvm-install` should be the install path of LLVM. If you installed LLVM elsewhere by `-DCMAKE_INSTALL_PREFIX` option when building LLVM, you need to change the path in `-DMLIR_DIR` accordingly. |
| 57 | + * The cmake option `-DLLVM_EXTERNAL_LIT` is for the tests of this project. It requires the `lit` tool to be installed in the system. You can install it via `pip install lit`. If you don't need to run the tests of this repo, you can omit this option in the command line. |
| 58 | + |
| 59 | +Graph Compiler supports the following build-time options. |
| 60 | + |
| 61 | +| CMake Option | Supported values (defaults in bold) | Description | |
| 62 | +|:--------------------------------|:---------------------------------------|:---------------------------------------------------------------------------------------| |
| 63 | +| GC_LEGACY_ENABLE | **ON**, OFF | Controls building the legacy graph-compiler component | |
| 64 | +| GC_TEST_ENABLE | **ON**, OFF | Controls building the tests | |
| 65 | +| GC_DEV_LINK_LLVM_DYLIB | ON, **OFF** | Controls dynamic link LLVM/MLIR libraries, mainly for developer | |
| 66 | + |
0 commit comments