Skip to content

Commit

Permalink
[onnx-frontend] Update onnx-frontend Readme (#468)
Browse files Browse the repository at this point in the history
This PR updates the build instructions for onnx-frontend.
  • Loading branch information
Connor-XY authored Oct 22, 2024
1 parent ad03738 commit cdfc595
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
46 changes: 42 additions & 4 deletions frontends/onnx-frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ ONNX-Frontend is a project to build customized onnx graph --> onnx dialect --> s

## Quick Start

### Prerequisites
```
python >= 3.7
gcc >= 6.4
protobuf >= 4.21.12
cmake >= 3.13.4
make >= 4.2.1 or ninja >= 1.10.2
java >= 1.11 (optional)
```

Look [here](https://github.com/onnx/onnx-mlir/blob/main/docs/Prerequisite.md) for help to set up the prerequisite software.


### Prepare
```
git clone https://github.com/bytedance/byteir.git
Expand All @@ -17,11 +30,36 @@ git submodule update --init --recursive $ONNX_MLIR_ROOT
cd $ONNX_MLIR_ROOT && git apply $ONNX_FRONTEND_ROOT/third_party/patches/OnnxMlir*.patch
cd $ONNX_OFFICIAL_ROOT && git apply $ONNX_FRONTEND_ROOT/third_party/patches/OnnxOfficial*.patch
pip3 install lit>=14.0.0
cd $ONNX_FRONTEND_ROOT
python3 -m pip install -r requirements.txt
```

### Build onnx-frontend from source code and run
First, build MLIR (llvm-project commit `b2cdf3cc4c08729d0ff582d55e40793a20bbcdcc`) with cmake option `-DLLVM_ENABLE_RTTI=ON`.
Firstly, build MLIR (llvm-project commit `b2cdf3cc4c08729d0ff582d55e40793a20bbcdcc`) with cmake option `-DLLVM_ENABLE_RTTI=ON`.
```
git clone -n https://github.com/llvm/llvm-project.git
cd llvm-project && git checkout b2cdf3cc4c08729d0ff582d55e40793a20bbcdcc && cd ..
```

```
mkdir llvm-project/build
cd llvm-project/build
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_TARGETS_TO_BUILD="host" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_ENABLE_LIBEDIT=OFF
cmake --build . -- ${MAKEFLAGS}
cmake --build . --target check-mlir
cd ../..
MLIR_DIR=$(pwd)/llvm-project/build/lib/cmake/mlir
```

Then,
```
mkdir $ONNX_FRONTEND_ROOT/build
Expand All @@ -30,9 +68,9 @@ cmake "-H$ONNX_FRONTEND_ROOT" \
"-B$ONNX_FRONTEND_ROOT/build" \
-GNinja \
-DCMAKE_CXX_COMPILER=/usr/bin/c++ \
-DPython3_ROOT_DIR=/usr/bin/python3.7 \
-DPython3_ROOT_DIR=$(which python3) \
-DPY_VERSION=3 \
-DMLIR_DIR="${YOUR_MLIR_DIR}/lib/cmake/mlir" \
-DMLIR_DIR=${MLIR_DIR} \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_EXTERNAL_LIT=$(which lit)
Expand Down
4 changes: 2 additions & 2 deletions frontends/onnx-frontend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
lit>=14.0.0
numpy>=1.21.6
onnx==1.13.0
onnxruntime==1.13.1
onnxruntime>=1.13.1
# protobuf==3.20.1
pytest>=7.1.2
torch>=1.12.0
torch>=1.12.0

0 comments on commit cdfc595

Please sign in to comment.