Skip to content

Commit

Permalink
Disabled building tests default (like LLVM), enabled for our CIs
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com>
  • Loading branch information
AlexandreEichenberger committed Dec 2, 2024
1 parent f2ec420 commit 6939f8e
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ cmake_minimum_required(VERSION 3.20.0)

project(onnx-mlir)

option(ONNX_MLIR_BUILD_TESTS "Build ONNX-MLIR test executables. If OFF, just generate build targets." ON)
# Like in LLVM, default tests are off. Lit-tests are always on.
option(ONNX_MLIR_BUILD_TESTS "Build ONNX-MLIR test executables. If OFF, just generate build targets." OFF)
option(ONNX_MLIR_CCACHE_BUILD "Set to ON for a ccache enabled build." OFF)
option(ONNX_MLIR_ENABLE_STABLEHLO "Enable StableHLO support." ON)
option(ONNX_MLIR_ENABLE_WERROR "Enable warnings as errors." OFF)
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.onnx-mlir
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ RUN LLVM_PROJECT_ROOT=${WORK_DIR}/llvm-project \
&& CC=clang CXX=clang++ \
cmake -DMLIR_DIR=${LLVM_PROJECT_ROOT}/build/lib/cmake/mlir \
-DCMAKE_BUILD_TYPE=Release \
-DONNX_MLIR_BUILD_TESTS=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_INSTALL_MESSAGE=NEVER \
-DONNX_MLIR_ACCELERATORS=${ACCEL} .. \
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.onnx-mlir-dev
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN LLVM_PROJECT_ROOT=${WORK_DIR}/llvm-project \
&& CC=clang CXX=clang++ \
cmake -DMLIR_DIR=${LLVM_PROJECT_ROOT}/build/lib/cmake/mlir \
-DCMAKE_BUILD_TYPE=Debug \
-DONNX_MLIR_BUILD_TESTS=ON \
-DONNX_MLIR_TEST_OPTLEVEL=0 \
-DONNX_MLIR_ACCELERATORS=${ACCEL} .. \
# Run the cppcheck scanner on s390x
Expand Down
6 changes: 6 additions & 0 deletions docs/BuildOnLinuxOSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ This project uses lit ([LLVM's Integrated Tester](https://llvm.org/docs/CommandG

To build ONNX-MLIR, use the following commands (maybe with additional `-DCMAKE_CXX_FLAGS` argument described [below](#enable-cpu-optimizations)):

To build a version with extended tests, keep the `-DONNX_MLIR_BUILD_TESTS=ON` line below.
Note that the extended tests requires the installation of `onnx` via a pip install of `third_party/onnx`. To build a version without a dependence on `third_party/onnx`, remove the `-DONNX_MLIR_BUILD_TESTS=ON` line or set to `OFF`.
The lightweight Literal tests are build regardless of this option.

[same-as-file]: <> ({"ref": "utils/install-onnx-mlir.sh", "skip-doc": 2})
```bash
git clone --recursive https://github.com/onnx/onnx-mlir.git
Expand All @@ -68,13 +72,15 @@ if [[ -z "$pythonLocation" ]]; then
cmake -G Ninja \
-DCMAKE_CXX_COMPILER=/usr/bin/c++ \
-DCMAKE_BUILD_TYPE=Release \
-DONNX_MLIR_BUILD_TESTS=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DMLIR_DIR=${MLIR_DIR} \
..
else
cmake -G Ninja \
-DCMAKE_CXX_COMPILER=/usr/bin/c++ \
-DCMAKE_BUILD_TYPE=Release \
-DONNX_MLIR_BUILD_TESTS=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DPython3_ROOT_DIR=$pythonLocation \
-DMLIR_DIR=${MLIR_DIR} \
Expand Down
4 changes: 4 additions & 0 deletions docs/BuildOnWindows.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ call cmake --build . --config Release
```
After the above commands succeed, an `onnx-mlir` executable should appear in the `Debug/bin` or `Release/bin` directory.

To build a version with extended tests, add the `-DONNX_MLIR_BUILD_TESTS=ON` line above.
Note that the extended tests requires the installation of `onnx` via a pip install of `third_party/onnx`. To build a version without a dependence on `third_party/onnx`, do not add the `-DONNX_MLIR_BUILD_TESTS=ON` line or set to `OFF`.
The lightweight Literal tests are build regardless of this option.

### Trouble shooting build issues

Check this [page](TestingHighLevel.md) for helpful hints.
4 changes: 4 additions & 0 deletions docs/doc_check/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

if (NOT ONNX_MLIR_BUILD_TESTS)
set(EXCLUDE_FROM_ALL ON)
endif()

set(check_cmd ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/check.py)

add_custom_target(check-doc
Expand Down
4 changes: 4 additions & 0 deletions test/accelerators/NNPA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

if (NOT ONNX_MLIR_BUILD_TESTS)
set(EXCLUDE_FROM_ALL ON)
endif()

add_custom_target(check-onnx-backend-numerical-nnpa)

add_subdirectory(backend)
Expand Down
4 changes: 4 additions & 0 deletions test/backend-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

if (NOT ONNX_MLIR_BUILD_TESTS)
set(EXCLUDE_FROM_ALL ON)
endif()

add_custom_target(backend-cpp)
set_target_properties(backend-cpp PROPERTIES FOLDER "Tests")

Expand Down
4 changes: 4 additions & 0 deletions test/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

if (NOT ONNX_MLIR_BUILD_TESTS)
set(EXCLUDE_FROM_ALL ON)
endif()

file(GENERATE
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/conftest.py
INPUT ${CMAKE_CURRENT_SOURCE_DIR}/conftest.py
Expand Down
4 changes: 4 additions & 0 deletions test/compilerlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

if (NOT ONNX_MLIR_BUILD_TESTS)
set(EXCLUDE_FROM_ALL ON)
endif()

add_onnx_mlir_executable(CompilerLibTest
CompilerLibTest.cpp

Expand Down
2 changes: 2 additions & 0 deletions test/mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: Apache-2.0

# Just like LLVM, ONNX_MLIR_BUILD_TESTS=false does not disable lit tests.

# Turn on lit test for specified accelerators even if the
# accelerator code itself cannot be built.
if (ONNX_MLIR_ACCELERATORS)
Expand Down
4 changes: 4 additions & 0 deletions test/modellib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

if (NOT ONNX_MLIR_BUILD_TESTS)
set(EXCLUDE_FROM_ALL ON)
endif()

add_onnx_mlir_library(ModelLib
CategoryMapperModel.cpp
ConvModel.cpp
Expand Down
4 changes: 4 additions & 0 deletions test/numerical/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

if (NOT ONNX_MLIR_BUILD_TESTS)
set(EXCLUDE_FROM_ALL ON)
endif()

add_custom_target(numerical)
set_target_properties(numerical PROPERTIES FOLDER "Tests")

Expand Down
4 changes: 4 additions & 0 deletions test/perf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

if (NOT ONNX_MLIR_BUILD_TESTS)
set(EXCLUDE_FROM_ALL ON)
endif()

add_onnx_mlir_library(PerfLib
PerfHelper.cpp
EXCLUDE_FROM_OM_LIBS
Expand Down
4 changes: 4 additions & 0 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

if (NOT ONNX_MLIR_BUILD_TESTS)
set(EXCLUDE_FROM_ALL ON)
endif()

add_custom_target(unittest)
set_target_properties(unittest PROPERTIES FOLDER "Tests")

Expand Down
2 changes: 2 additions & 0 deletions utils/install-onnx-mlir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ if [[ -z "$pythonLocation" ]]; then
cmake -G Ninja \
-DCMAKE_CXX_COMPILER=/usr/bin/c++ \
-DCMAKE_BUILD_TYPE=Release \
-DONNX_MLIR_BUILD_TESTS=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DMLIR_DIR=${MLIR_DIR} \
..
else
cmake -G Ninja \
-DCMAKE_CXX_COMPILER=/usr/bin/c++ \
-DCMAKE_BUILD_TYPE=Release \
-DONNX_MLIR_BUILD_TESTS=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DPython3_ROOT_DIR=$pythonLocation \
-DMLIR_DIR=${MLIR_DIR} \
Expand Down

0 comments on commit 6939f8e

Please sign in to comment.