Skip to content

Commit 5094f11

Browse files
authored
Merge pull request #21 from IITH-Compilers/mlbridge-test
CMake flag for enabling tests
2 parents 6e57f4e + 2c581d7 commit 5094f11

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

.github/workflows/mlbridge_build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ cmake \
4343
-DCMAKE_BUILD_TYPE="$BUILD" \
4444
-DCMAKE_INSTALL_PREFIX=$REPO_DIR/install \
4545
-DPROTOS_DIRECTORY=$REPO_DIR/test/protos \
46-
-DPYTHON_UTILITIES_DIRECTORY=$REPO_DIR/test
46+
-DPYTHON_UTILITIES_DIRECTORY=$REPO_DIR/test \
47+
-DMLBRIDGE_ENABLE_TEST=ON
4748

4849
make -j -C $REPO_DIR/build_${BUILD,,} install

CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ endif()
3838

3939
add_subdirectory(MLModelRunner)
4040
add_subdirectory(SerDes)
41-
add_subdirectory(test)
41+
if(MLBRIDGE_ENABLE_TEST)
42+
add_subdirectory(test)
43+
endif()
4244

4345
if(LLVM_MLBRIDGE)
4446
include(AddLLVM)
@@ -78,12 +80,12 @@ else()
7880
set_property(TARGET MLCompilerBridgeC PROPERTY POSITION_INDEPENDENT_CODE 1)
7981
set_target_properties(MLCompilerBridgeC PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
8082
install(TARGETS MLCompilerBridgeC DESTINATION lib)
81-
82-
add_executable(MLCompilerBridgeTest $<TARGET_OBJECTS:MLBridgeCPPTest>)
83-
target_link_libraries(MLCompilerBridgeTest PUBLIC MLCompilerBridge)
84-
set_target_properties(MLCompilerBridgeTest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
85-
install(TARGETS MLCompilerBridgeTest DESTINATION bin)
86-
83+
if(MLBRIDGE_ENABLE_TEST)
84+
add_executable(MLCompilerBridgeTest $<TARGET_OBJECTS:MLBridgeCPPTest>)
85+
target_link_libraries(MLCompilerBridgeTest PUBLIC MLCompilerBridge)
86+
set_target_properties(MLCompilerBridgeTest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
87+
install(TARGETS MLCompilerBridgeTest DESTINATION bin)
88+
endif()
8789
endif(LLVM_MLBRIDGE)
8890

8991
install(DIRECTORY include/ DESTINATION include)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ Please see [here](https://iith-compilers.github.io/ML-Compiler-Bridge/) for docu
4141
## Setup
4242
`ML-Compiler-Bridge` can be built as a stand-alone library to generate `.a` files that can in turn be linked with any compiler.
4343
1. `mkdir build && cd build`
44-
2. `cmake [-DCMAKE_BUILD_TYPE=Release|Debug] [-DCMAKE_INSTALL_PREFIX=<Install_path>] -DONNXRUNTIME_ROOTDIR=<Path to ONNX install dir> -DPROTOS_DIRECTORY=<Path to protobuf files> -DTENSORFLOW_AOT_PATH=<Path to TensorFlow pip install dir> ../`
44+
2. `cmake [-DCMAKE_BUILD_TYPE=Release|Debug] [-DCMAKE_INSTALL_PREFIX=<Install_path>] [-DMLBRIDGE_ENABLE_TEST=ON|OFF] -DONNXRUNTIME_ROOTDIR=<Path to ONNX install dir> -DPROTOS_DIRECTORY=<Path to protobuf files> -DTENSORFLOW_AOT_PATH=<Path to TensorFlow pip install dir> ../`
4545
3. `make -j [&& make install]`
4646

4747
This process would generate `libMLCompilerBridge.a` and `libMLCompilerBridgeC.a` libraries under `build/lib` directory, required headers under `build/include` directory. `libMLCompilerBridgeC.a` exposes C APIs for using with C-based compilers like Pluto, where as `libMLCompilerBridge.a` exposes C++ APIs that can be used with any compiler written in C++.
4848

4949
Python end points are available under [`CompilerInterface`](./CompilerInterface/).
5050

51-
To ensure the correctness, run `make verify-all`
51+
To ensure the correctness, run `make verify-all`. This would need enabling tests in cmake (`-DMLBRIDGE_ENABLE_TEST=ON`) and `PROTOS_DIRECTORY` should point to `test/protos`.
5252

5353
### Using ML-Compiler-Bridge with LLVM and MLIR
5454

0 commit comments

Comments
 (0)