Skip to content

Commit

Permalink
Merge pull request microsoft#56 from NonStatic2014/bohu/rename
Browse files Browse the repository at this point in the history
Rename to onnxruntime server
  • Loading branch information
NonStatic2014 authored Apr 26, 2019
2 parents 17c6220 + 00078cd commit 1cd43ab
Show file tree
Hide file tree
Showing 61 changed files with 446 additions and 440 deletions.
4 changes: 2 additions & 2 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ The complete list of build options can be found by running `./build.sh (or ./bui
1. For Windows, just add --x86 argument when launching build.bat
2. For Linux, it must be built out of a x86 os, --x86 argument also needs be specified to build.sh
## Build Hosting Application on Linux
## Build ONNX Runtime Server on Linux
1. In the ONNX Runtime root folder, run `./build.sh --config RelWithDebInfo --build_hosting --use_openmp --parallel`
1. In the ONNX Runtime root folder, run `./build.sh --config RelWithDebInfo --build_server --use_openmp --parallel`
## Build/Test Flavors for CI
Expand Down
6 changes: 3 additions & 3 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ option(onnxruntime_USE_BRAINSLICE "Build with BrainSlice" OFF)
option(onnxruntime_USE_TENSORRT "Build with TensorRT support" OFF)
option(onnxruntime_ENABLE_LTO "Enable link time optimization, which is not stable on older GCCs" OFF)
option(onnxruntime_CROSS_COMPILING "Cross compiling onnx runtime" OFF)
option(onnxruntime_BUILD_HOSTING "Build ONNX hosting service" OFF)
option(onnxruntime_BUILD_SERVER "Build ONNX Runtime Server" OFF)
option(onnxruntime_USE_FULL_PROTOBUF "Use full protobuf" OFF)
option(onnxruntime_DISABLE_CONTRIB_OPS "Disable contrib ops" OFF)
option(onnxruntime_USE_EIGEN_THREADPOOL "Use eigen threadpool. Otherwise OpenMP or a homemade one will be used" OFF)
Expand Down Expand Up @@ -608,8 +608,8 @@ if (onnxruntime_BUILD_SHARED_LIB)
include(onnxruntime.cmake)
endif()

if (onnxruntime_BUILD_HOSTING)
include(onnxruntime_hosting.cmake)
if (onnxruntime_BUILD_SERVER)
include(onnxruntime_server.cmake)
endif()

# some of the tests rely on the shared libs to be
Expand Down
3 changes: 3 additions & 0 deletions cmake/get_boost.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

set(BOOST_REQUESTED_VERSION 1.69.0 CACHE STRING "")
set(BOOST_SHA1 8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406 CACHE STRING "")
set(BOOST_USE_STATIC_LIBS true CACHE BOOL "")
Expand Down
120 changes: 0 additions & 120 deletions cmake/onnxruntime_hosting.cmake

This file was deleted.

120 changes: 120 additions & 0 deletions cmake/onnxruntime_server.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

set(SERVER_APP_NAME "onnxruntime_server")

# Generate .h and .cc files from protobuf file
add_library(server_proto
${ONNXRUNTIME_ROOT}/server/protobuf/predict.proto)
target_include_directories(server_proto PUBLIC $<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES> "${CMAKE_CURRENT_BINARY_DIR}/.." ${CMAKE_CURRENT_BINARY_DIR}/onnx)
target_compile_definitions(server_proto PUBLIC $<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>)
onnxruntime_protobuf_generate(APPEND_PATH IMPORT_DIRS ${REPO_ROOT}/cmake/external/protobuf/src ${ONNXRUNTIME_ROOT}/server/protobuf ${ONNXRUNTIME_ROOT}/core/protobuf TARGET server_proto)
add_dependencies(server_proto onnx_proto ${onnxruntime_EXTERNAL_DEPENDENCIES})
if(NOT WIN32)
if(HAS_UNUSED_PARAMETER)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/model_metadata.pb.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/model_status.pb.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/predict.pb.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
endif()
endif()

# Setup dependencies
include(get_boost.cmake)
set(re2_src ${REPO_ROOT}/cmake/external/re2)

# Setup source code
set(onnxruntime_server_lib_srcs
"${ONNXRUNTIME_ROOT}/server/http/json_handling.cc"
"${ONNXRUNTIME_ROOT}/server/http/predict_request_handler.cc"
"${ONNXRUNTIME_ROOT}/server/http/util.cc"
"${ONNXRUNTIME_ROOT}/server/environment.cc"
"${ONNXRUNTIME_ROOT}/server/executor.cc"
"${ONNXRUNTIME_ROOT}/server/converter.cc"
"${ONNXRUNTIME_ROOT}/server/util.cc"
)
if(NOT WIN32)
if(HAS_UNUSED_PARAMETER)
set_source_files_properties(${ONNXRUNTIME_ROOT}/server/http/json_handling.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties(${ONNXRUNTIME_ROOT}/server/http/predict_request_handler.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties(${ONNXRUNTIME_ROOT}/server/executor.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties(${ONNXRUNTIME_ROOT}/server/converter.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties(${ONNXRUNTIME_ROOT}/server/util.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
endif()
endif()

file(GLOB_RECURSE onnxruntime_server_http_core_lib_srcs
"${ONNXRUNTIME_ROOT}/server/http/core/*.cc"
)

file(GLOB_RECURSE onnxruntime_server_srcs
"${ONNXRUNTIME_ROOT}/server/main.cc"
)

# HTTP core library
add_library(onnxruntime_server_http_core_lib STATIC
${onnxruntime_server_http_core_lib_srcs})
target_include_directories(onnxruntime_server_http_core_lib
PUBLIC
${ONNXRUNTIME_ROOT}/server/http/core
${Boost_INCLUDE_DIR}
${re2_src}
)
add_dependencies(onnxruntime_server_http_core_lib Boost)
target_link_libraries(onnxruntime_server_http_core_lib PRIVATE
${Boost_LIBRARIES}
)

# Server library
add_library(onnxruntime_server_lib ${onnxruntime_server_lib_srcs})
onnxruntime_add_include_to_target(onnxruntime_server_lib gsl onnx_proto server_proto)
target_include_directories(onnxruntime_server_lib PRIVATE
${ONNXRUNTIME_ROOT}
${CMAKE_CURRENT_BINARY_DIR}/onnx
${ONNXRUNTIME_ROOT}/server
${ONNXRUNTIME_ROOT}/server/http
PUBLIC
${Boost_INCLUDE_DIR}
${re2_src}
)

target_link_libraries(onnxruntime_server_lib PRIVATE
server_proto
${Boost_LIBRARIES}
onnxruntime_server_http_core_lib
onnxruntime_session
onnxruntime_optimizer
onnxruntime_providers
onnxruntime_util
onnxruntime_framework
onnxruntime_util
onnxruntime_graph
onnxruntime_common
onnxruntime_mlas
${onnxruntime_EXTERNAL_LIBRARIES}
)

# For IDE only
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_server_srcs} ${onnxruntime_server_lib_srcs} ${onnxruntime_server_lib})

# Server Application
add_executable(${SERVER_APP_NAME} ${onnxruntime_server_srcs})
add_dependencies(${SERVER_APP_NAME} onnx server_proto onnx_proto ${onnxruntime_EXTERNAL_DEPENDENCIES})

if(NOT WIN32)
if(HAS_UNUSED_PARAMETER)
set_source_files_properties("${ONNXRUNTIME_ROOT}/server/main.cc" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
endif()
endif()

onnxruntime_add_include_to_target(${SERVER_APP_NAME} onnxruntime_session onnxruntime_server_lib gsl onnx onnx_proto server_proto)

target_include_directories(${SERVER_APP_NAME} PRIVATE
${ONNXRUNTIME_ROOT}
${ONNXRUNTIME_ROOT}/server/http
)

target_link_libraries(${SERVER_APP_NAME} PRIVATE
onnxruntime_server_http_core_lib
onnxruntime_server_lib
)

61 changes: 32 additions & 29 deletions cmake/onnxruntime_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ set(onnxruntime_test_framework_libs
onnxruntime_mlas
)

set(onnxruntime_test_hosting_libs
set(onnxruntime_test_server_libs
onnxruntime_test_utils
onnxruntime_test_utils_for_hosting
onnxruntime_test_utils_for_server
)

if(WIN32)
Expand Down Expand Up @@ -552,52 +552,55 @@ if (onnxruntime_BUILD_SHARED_LIB)
endif()
endif()

if (onnxruntime_BUILD_HOSTING)
file(GLOB onnxruntime_test_hosting_src
"${TEST_SRC_DIR}/hosting/unit_tests/*.cc"
"${TEST_SRC_DIR}/hosting/unit_tests/*.h"
if (onnxruntime_BUILD_SERVER)
file(GLOB onnxruntime_test_server_src
"${TEST_SRC_DIR}/server/unit_tests/*.cc"
"${TEST_SRC_DIR}/server/unit_tests/*.h"
)

file(GLOB onnxruntime_integration_test_hosting_src
"${TEST_SRC_DIR}/hosting/integration_tests/*.py"
file(GLOB onnxruntime_integration_test_server_src
"${TEST_SRC_DIR}/server/integration_tests/*.py"
)
if(NOT WIN32)
if(HAS_UNUSED_PARAMETER)
set_source_files_properties("${TEST_SRC_DIR}/hosting/unit_tests/json_handling_tests.cc" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties("${TEST_SRC_DIR}/hosting/unit_tests/converter_tests.cc" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties("${TEST_SRC_DIR}/hosting/unit_tests/util_tests.cc" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties("${TEST_SRC_DIR}/server/unit_tests/json_handling_tests.cc" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties("${TEST_SRC_DIR}/server/unit_tests/converter_tests.cc" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties("${TEST_SRC_DIR}/server/unit_tests/util_tests.cc" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
endif()
endif()

add_library(onnxruntime_test_utils_for_hosting ${onnxruntime_test_hosting_src})
onnxruntime_add_include_to_target(onnxruntime_test_utils_for_hosting onnxruntime_test_utils gtest gmock gsl onnx onnx_proto hosting_proto)
add_dependencies(onnxruntime_test_utils_for_hosting onnxruntime_hosting_lib onnxruntime_hosting_http_core_lib Boost ${onnxruntime_EXTERNAL_DEPENDENCIES})
target_include_directories(onnxruntime_test_utils_for_hosting PUBLIC ${Boost_INCLUDE_DIR} ${REPO_ROOT}/cmake/external/re2 ${CMAKE_CURRENT_BINARY_DIR}/onnx ${ONNXRUNTIME_ROOT}/hosting/http ${ONNXRUNTIME_ROOT}/hosting/http/core PRIVATE ${ONNXRUNTIME_ROOT} )
target_link_libraries(onnxruntime_test_utils_for_hosting ${Boost_LIBRARIES} ${onnx_test_libs})
add_library(onnxruntime_test_utils_for_server ${onnxruntime_test_server_src})
onnxruntime_add_include_to_target(onnxruntime_test_utils_for_server onnxruntime_test_utils gtest gmock gsl onnx onnx_proto server_proto)
add_dependencies(onnxruntime_test_utils_for_server onnxruntime_server_lib onnxruntime_server_http_core_lib Boost ${onnxruntime_EXTERNAL_DEPENDENCIES})
target_include_directories(onnxruntime_test_utils_for_server PUBLIC ${Boost_INCLUDE_DIR} ${REPO_ROOT}/cmake/external/re2 ${CMAKE_CURRENT_BINARY_DIR}/onnx ${ONNXRUNTIME_ROOT}/server/http ${ONNXRUNTIME_ROOT}/server/http/core PRIVATE ${ONNXRUNTIME_ROOT} )
target_link_libraries(onnxruntime_test_utils_for_server ${Boost_LIBRARIES} ${onnx_test_libs})

AddTest(
TARGET onnxruntime_hosting_tests
SOURCES ${onnxruntime_test_hosting_src}
LIBS ${onnxruntime_test_hosting_libs} hosting_proto onnxruntime_hosting_lib ${onnxruntime_test_providers_libs}
TARGET onnxruntime_server_tests
SOURCES ${onnxruntime_test_server_src}
LIBS ${onnxruntime_test_server_libs} server_proto onnxruntime_server_lib ${onnxruntime_test_providers_libs}
DEPENDS ${onnxruntime_EXTERNAL_DEPENDENCIES}
)

onnxruntime_protobuf_generate(
APPEND_PATH IMPORT_DIRS ${REPO_ROOT}/cmake/external/protobuf/src ${ONNXRUNTIME_ROOT}/hosting/protobuf ${ONNXRUNTIME_ROOT}/core/protobuf
PROTOS ${ONNXRUNTIME_ROOT}/hosting/protobuf/predict.proto ${ONNXRUNTIME_ROOT}/hosting/protobuf/onnx-ml.proto
APPEND_PATH IMPORT_DIRS ${REPO_ROOT}/cmake/external/protobuf/src ${ONNXRUNTIME_ROOT}/server/protobuf ${ONNXRUNTIME_ROOT}/core/protobuf
PROTOS ${ONNXRUNTIME_ROOT}/server/protobuf/predict.proto ${ONNXRUNTIME_ROOT}/server/protobuf/onnx-ml.proto
LANGUAGE python
TARGET onnxruntime_hosting_tests
OUT_VAR hosting_test_py)
TARGET onnxruntime_server_tests
OUT_VAR server_test_py)

add_custom_command(
TARGET onnxruntime_hosting_tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${test_data_target}>/hosting_test
TARGET onnxruntime_server_tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/server_test
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_integration_test_hosting_src}
$<TARGET_FILE_DIR:${test_data_target}>/hosting_test/
${onnxruntime_integration_test_server_src}
${CMAKE_CURRENT_BINARY_DIR}/server_test/
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE_DIR:${test_data_target}>/*_pb2.py
$<TARGET_FILE_DIR:${test_data_target}>/hosting_test/
${CMAKE_CURRENT_BINARY_DIR}/onnx_ml_pb2.py
${CMAKE_CURRENT_BINARY_DIR}/server_test/
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/predict_pb2.py
${CMAKE_CURRENT_BINARY_DIR}/server_test/
)

endif()
Expand Down
Loading

0 comments on commit 1cd43ab

Please sign in to comment.