From 745e5b9221400d22eab6f1fa66aed8b393b8cedf Mon Sep 17 00:00:00 2001 From: Ettore Tiotto Date: Mon, 10 Jan 2022 18:25:54 -0500 Subject: [PATCH] Add check-onnx-backend to Mac CI. (#1069) * Add check-onnx-backend to Mac CI. Signed-off-by: Ettore Tiotto --- .github/workflows/macos-amd64-build.yml | 14 ++++++++++---- CMakeLists.txt | 1 + README.md | 9 +++++++-- utils/check-onnx-backend.sh | 3 +++ utils/install-onnx-mlir.sh | 6 +++++- 5 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 utils/check-onnx-backend.sh diff --git a/.github/workflows/macos-amd64-build.yml b/.github/workflows/macos-amd64-build.yml index 21b5a99362f5..8e69a5166e95 100644 --- a/.github/workflows/macos-amd64-build.yml +++ b/.github/workflows/macos-amd64-build.yml @@ -11,11 +11,9 @@ jobs: submodules: recursive - uses: actions/setup-python@v2 with: - python-version: '3.7' + python-version: '3.9' - name: install tools that are needed for compilation - run: brew install ninja protobuf llvm - - name: install pytest-xdist - run: pip3 install pytest-xdist + run: brew install ninja protobuf pybind11 - name: cache MLIR directory id: cache-mlir uses: actions/cache@v2 @@ -30,10 +28,18 @@ jobs: cd ~/work/onnx-mlir sh ~/work/onnx-mlir/onnx-mlir/utils/clone-mlir.sh sh ~/work/onnx-mlir/onnx-mlir/utils/build-mlir.sh + - name: install third_party/onnx + run: | + cd ~/work/onnx-mlir/onnx-mlir + pip3 install -e third_party/onnx - name: build onnx-mlir run: | cd ~/work/onnx-mlir sh ~/work/onnx-mlir/onnx-mlir/utils/install-onnx-mlir.sh + - name: run onnx-mlir backend tests + run: | + cd ~/work/onnx-mlir + sh ~/work/onnx-mlir/onnx-mlir/utils/check-onnx-backend.sh - name: run onnx-mlir numerical tests run: | cd ~/work/onnx-mlir diff --git a/CMakeLists.txt b/CMakeLists.txt index 6efcad59f02a..323581a21e9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,7 @@ if (WIN32) # installed on the machine. set(Python3_FIND_REGISTRY NEVER) endif() + find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED COMPONENTS Interpreter Development) # Don't require AWT to allow headless JDK to reduce docker image size diff --git a/README.md b/README.md index 29c43696affe..931bec597eb4 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,11 @@ git clone --recursive https://github.com/onnx/onnx-mlir.git export MLIR_DIR=$(pwd)/llvm-project/build/lib/cmake/mlir mkdir onnx-mlir/build && cd onnx-mlir/build -cmake -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/c++ .. +if [[ -z "$pythonLocation" ]]; then + cmake -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/c++ .. +else + cmake -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DPython3_ROOT_DIR=$pythonLocation .. +fi cmake --build . # Run lit tests: @@ -163,7 +167,8 @@ cmake --build . --target check-onnx-lit ``` If you are running on OSX Big Sur, you need to add `-DCMAKE_CXX_COMPILER=/usr/bin/c++` -to the `cmake ..` command due to changes in the compilers. +to the `cmake ..` command due to changes in the compilers. The environment variable +`$pythonLocation` may be used to specify the base directory of the Python compiler. After the above commands succeed, an `onnx-mlir` executable should appear in the `bin` directory. ##### LLVM and ONNX-MLIR CMake variables diff --git a/utils/check-onnx-backend.sh b/utils/check-onnx-backend.sh new file mode 100644 index 000000000000..4d535224a358 --- /dev/null +++ b/utils/check-onnx-backend.sh @@ -0,0 +1,3 @@ +# Run backend tests. +cd onnx-mlir/build +cmake --build . --target check-onnx-backend diff --git a/utils/install-onnx-mlir.sh b/utils/install-onnx-mlir.sh index 2bff478e933b..e7bf8d3ab14e 100755 --- a/utils/install-onnx-mlir.sh +++ b/utils/install-onnx-mlir.sh @@ -2,7 +2,11 @@ export MLIR_DIR=$(pwd)/llvm-project/build/lib/cmake/mlir mkdir onnx-mlir/build && cd onnx-mlir/build -cmake -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/c++ .. +if [[ -z "$pythonLocation" ]]; then + cmake -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/c++ .. +else + cmake -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DPython3_ROOT_DIR=$pythonLocation .. +fi cmake --build . # Run lit tests: