Skip to content

Commit

Permalink
Merge pull request #21 from IITH-Compilers/mlbridge-test
Browse files Browse the repository at this point in the history
CMake flag for enabling tests
  • Loading branch information
svkeerthy committed Feb 23, 2024
2 parents 6e57f4e + 2c581d7 commit 5094f11
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/mlbridge_build.sh
Expand Up @@ -43,6 +43,7 @@ cmake \
-DCMAKE_BUILD_TYPE="$BUILD" \
-DCMAKE_INSTALL_PREFIX=$REPO_DIR/install \
-DPROTOS_DIRECTORY=$REPO_DIR/test/protos \
-DPYTHON_UTILITIES_DIRECTORY=$REPO_DIR/test
-DPYTHON_UTILITIES_DIRECTORY=$REPO_DIR/test \
-DMLBRIDGE_ENABLE_TEST=ON

make -j -C $REPO_DIR/build_${BUILD,,} install
16 changes: 9 additions & 7 deletions CMakeLists.txt
Expand Up @@ -38,7 +38,9 @@ endif()

add_subdirectory(MLModelRunner)
add_subdirectory(SerDes)
add_subdirectory(test)
if(MLBRIDGE_ENABLE_TEST)
add_subdirectory(test)
endif()

if(LLVM_MLBRIDGE)
include(AddLLVM)
Expand Down Expand Up @@ -78,12 +80,12 @@ else()
set_property(TARGET MLCompilerBridgeC PROPERTY POSITION_INDEPENDENT_CODE 1)
set_target_properties(MLCompilerBridgeC PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
install(TARGETS MLCompilerBridgeC DESTINATION lib)

add_executable(MLCompilerBridgeTest $<TARGET_OBJECTS:MLBridgeCPPTest>)
target_link_libraries(MLCompilerBridgeTest PUBLIC MLCompilerBridge)
set_target_properties(MLCompilerBridgeTest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
install(TARGETS MLCompilerBridgeTest DESTINATION bin)

if(MLBRIDGE_ENABLE_TEST)
add_executable(MLCompilerBridgeTest $<TARGET_OBJECTS:MLBridgeCPPTest>)
target_link_libraries(MLCompilerBridgeTest PUBLIC MLCompilerBridge)
set_target_properties(MLCompilerBridgeTest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
install(TARGETS MLCompilerBridgeTest DESTINATION bin)
endif()
endif(LLVM_MLBRIDGE)

install(DIRECTORY include/ DESTINATION include)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -41,14 +41,14 @@ Please see [here](https://iith-compilers.github.io/ML-Compiler-Bridge/) for docu
## Setup
`ML-Compiler-Bridge` can be built as a stand-alone library to generate `.a` files that can in turn be linked with any compiler.
1. `mkdir build && cd build`
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> ../`
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> ../`
3. `make -j [&& make install]`

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++.

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

To ensure the correctness, run `make verify-all`
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`.

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

Expand Down

0 comments on commit 5094f11

Please sign in to comment.