Skip to content

Commit

Permalink
Merge pull request #25 from IITH-Compilers/onnx-config
Browse files Browse the repository at this point in the history
Added FindOnnx cmake, Removed JSON.cpp & JSON.h copies, upgraded gRPC + protobuf.
  • Loading branch information
svkeerthy committed May 14, 2024
2 parents 336ade4 + ccf7514 commit 53bf989
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 2,168 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
activate-environment: mlbridge
environment-file: mlbridge.yml
- name: Install other dependencies and build
run: bash .github/workflows/mlbridge_build.sh release
run: bash .github/workflows/mlbridge_build.sh Release
- name: Setup Conda dependencies
uses: conda-incubator/setup-miniconda@v2
with:
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/mlbridge_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@
export MY_INSTALL_DIR=$HOME/.local
mkdir -p $MY_INSTALL_DIR
export PATH="$MY_INSTALL_DIR/bin:$PATH"
git clone --recurse-submodules -b v1.34.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc
git clone --recurse-submodules -b v1.58.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc

cd grpc
mkdir -p cmake/build
pushd cmake/build
cmake -DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
-DABSL_PROPAGATE_CXX_STD=OFF \
-DCMAKE_CXX_STANDARD=17 \
-G Ninja \
../..
make -j
make install
ninja
ninja install
popd

# Setup ONNXRuntime
Expand All @@ -35,7 +38,7 @@ if [[ -z "$BUILD" ]]; then
fi

cmake \
-G "Unix Makefiles" \
-G Ninja \
-S $REPO_DIR \
-B $REPO_DIR/build_${BUILD,,} \
-DONNXRUNTIME_ROOTDIR=$HOME/onnxruntime-linux-x64-1.16.3 \
Expand All @@ -46,4 +49,5 @@ cmake \
-DPYTHON_UTILITIES_DIRECTORY=$REPO_DIR/test \
-DMLBRIDGE_ENABLE_TEST=ON

make -j -C $REPO_DIR/build_${BUILD,,} install
cd $REPO_DIR/build_${BUILD,,}
ninja install
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ find_package(Protobuf CONFIG REQUIRED)
set(protobuf_MODULE_COMPATIBLE TRUE)
find_package(Protobuf CONFIG REQUIRED)

set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
${CMAKE_MODULE_PATH}
)
message("CMAKE Module path: ${CMAKE_MODULE_PATH}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Output directory for static libraries")

include_directories(${Protobuf_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
Expand Down Expand Up @@ -36,17 +42,20 @@ if(MLBRIDGE_DEBUG_MODE)
add_compile_definitions(DEBUG_MODE)
endif()

if(LLVM_MLBRIDGE)
include(AddLLVM)
include(HandleLLVMOptions)
include(LLVMDistributionSupport)
endif()

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

if(LLVM_MLBRIDGE)
include(AddLLVM)
include(HandleLLVMOptions)
include(LLVMDistributionSupport)

if(LLVM_MLBRIDGE)
add_llvm_library(LLVMMLBridge
tools.cpp

Expand Down
4 changes: 2 additions & 2 deletions MLModelRunner/C/PipeModelRunnerCWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ PipeModelRunnerWrapper *createPipeModelRunner(const char *OutboundName,
const char *InboundName,
int SerDesType) {
PipeModelRunnerWrapper *obj = new PipeModelRunnerWrapper();
obj->model = new PipeModelRunner(OutboundName, InboundName,
(BaseSerDes::Kind)SerDesType);
obj->model =
new PipeModelRunner(OutboundName, InboundName, (SerDesKind)SerDesType);
return obj;
}

Expand Down
7 changes: 4 additions & 3 deletions MLModelRunner/ONNXModelRunner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -DORT_NO_EXCEPTIONS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")

find_package(Onnxruntime REQUIRED)

#onnxruntime providers
option(onnxruntime_USE_CUDA "Build with CUDA support" OFF)
option(onnxruntime_USE_OPENVINO "Build with OpenVINO support" OFF)
Expand Down Expand Up @@ -50,6 +52,5 @@ add_library(ONNXModelRunnerLib OBJECT onnx.cpp
)
endif(LLVM_MLBRIDGE)

target_include_directories(ONNXModelRunnerLib PUBLIC "${ONNXRUNTIME_ROOTDIR}/include" "${ONNXRUNTIME_ROOTDIR}/include/onnxruntime/core/session" ${TENSORFLOW_AOT_PATH}/include)
target_link_directories(ONNXModelRunnerLib PUBLIC ${ONNXRUNTIME_ROOTDIR}/lib)
target_link_libraries(ONNXModelRunnerLib PRIVATE onnxruntime)
target_link_libraries(ONNXModelRunnerLib PRIVATE Onnxruntime::Onnxruntime)
target_include_directories(ONNXModelRunnerLib PUBLIC ${TENSORFLOW_AOT_PATH}/include)
2 changes: 1 addition & 1 deletion MLModelRunner/PipeModelRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using namespace llvm;

namespace MLBridge {
PipeModelRunner::PipeModelRunner(StringRef OutboundName, StringRef InboundName,
BaseSerDes::Kind SerDesType, LLVMContext *Ctx)
SerDesKind SerDesType, LLVMContext *Ctx)
: MLModelRunner(Kind::Pipe, SerDesType, Ctx),
InEC(sys::fs::openFileForRead(InboundName, Inbound)) {
this->InboundName = InboundName.str();
Expand Down
2 changes: 1 addition & 1 deletion MLModelRunner/gRPCModelRunner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ endif()
# Find gRPC installation
# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation.

find_package(gRPC 1.34.0 EXACT CONFIG REQUIRED)
find_package(gRPC 1.58.0 EXACT CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")

set(_GRPC_GRPCPP gRPC::grpc++)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Please see [here](https://iith-compilers.github.io/ML-Compiler-Bridge/) for docu
* GNU Make (4.2.1)
* LLVM (10.X) - [src](https://github.com/llvm/llvm-project/tree/release/10.x), [release](https://releases.llvm.org/download.html#10.0.1)
* Python (3.10), C++17
* gRPC v1.34 and protobuf v3.13 - for gRPC Model Runner
* Building GRPC from Source: Please follow [`Build GRPC with cmake`](https://grpc.io/docs/languages/cpp/quickstart/) v1.34 (protobuf v3.13) to build GRPC from source.
* gRPC v1.58 and protobuf v23.4 - for gRPC Model Runner
* Building GRPC from Source: Please follow [`Build GRPC with cmake`](https://grpc.io/docs/languages/cpp/quickstart/) v1.58 (protobuf v23.4) to build GRPC from source.
* In the above tutorial setting `DCMAKE_INSTALL_PREFIX` may not be necessary and the default install prefix can be used.
* The following dependencies will be required for Python: `pip install grpcio-tools`.
* [ONNXRuntime](https://github.com/microsoft/onnxruntime/releases) v1.13.1
Expand Down
6 changes: 3 additions & 3 deletions SerDes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ if(LLVM_MLBRIDGE)
bitstreamSerDes.cpp
protobufSerDes.cpp
tensorflowSerDes.cpp
JSON.cpp
)
target_compile_definitions(SerDesLib PRIVATE LLVM_MLBRIDGE)
else()
add_library(SerDesLib OBJECT TensorSpec.cpp jsonSerDes.cpp bitstreamSerDes.cpp protobufSerDes.cpp tensorflowSerDes.cpp JSON.cpp)
add_library(SerDesLib OBJECT TensorSpec.cpp jsonSerDes.cpp bitstreamSerDes.cpp protobufSerDes.cpp tensorflowSerDes.cpp)

add_library(SerDesCLib OBJECT TensorSpec.cpp jsonSerDes.cpp bitstreamSerDes.cpp JSON.cpp)
add_library(SerDesCLib OBJECT TensorSpec.cpp jsonSerDes.cpp bitstreamSerDes.cpp)
endif()
target_include_directories(SerDesLib PUBLIC ${TENSORFLOW_AOT_PATH}/include)
target_link_libraries(SerDesLib PRIVATE tf_xla_runtime)
Loading

0 comments on commit 53bf989

Please sign in to comment.