diff --git a/BUILD.md b/BUILD.md index db5ca3037f86c..98c1684de5b21 100644 --- a/BUILD.md +++ b/BUILD.md @@ -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 diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c717e86b75136..0f5b3d85881ea 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -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) @@ -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 diff --git a/cmake/get_boost.cmake b/cmake/get_boost.cmake index 5bcefa3479fd4..265d088698571 100644 --- a/cmake/get_boost.cmake +++ b/cmake/get_boost.cmake @@ -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 "") diff --git a/cmake/onnxruntime_hosting.cmake b/cmake/onnxruntime_hosting.cmake deleted file mode 100644 index 691703ac58a45..0000000000000 --- a/cmake/onnxruntime_hosting.cmake +++ /dev/null @@ -1,120 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -set(HOSTING_APP_NAME "onnxruntime_hosting") - -# Generate .h and .cc files from protobuf file -add_library(hosting_proto - ${ONNXRUNTIME_ROOT}/hosting/protobuf/predict.proto) -target_include_directories(hosting_proto PUBLIC $ "${CMAKE_CURRENT_BINARY_DIR}/.." ${CMAKE_CURRENT_BINARY_DIR}/onnx) -target_compile_definitions(hosting_proto PUBLIC $) -onnxruntime_protobuf_generate(APPEND_PATH IMPORT_DIRS ${REPO_ROOT}/cmake/external/protobuf/src ${ONNXRUNTIME_ROOT}/hosting/protobuf ${ONNXRUNTIME_ROOT}/core/protobuf TARGET hosting_proto) -add_dependencies(hosting_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_hosting_lib_srcs - "${ONNXRUNTIME_ROOT}/hosting/http/json_handling.cc" - "${ONNXRUNTIME_ROOT}/hosting/http/predict_request_handler.cc" - "${ONNXRUNTIME_ROOT}/hosting/http/util.cc" - "${ONNXRUNTIME_ROOT}/hosting/environment.cc" - "${ONNXRUNTIME_ROOT}/hosting/executor.cc" - "${ONNXRUNTIME_ROOT}/hosting/converter.cc" - "${ONNXRUNTIME_ROOT}/hosting/util.cc" - ) -if(NOT WIN32) - if(HAS_UNUSED_PARAMETER) - set_source_files_properties(${ONNXRUNTIME_ROOT}/hosting/http/json_handling.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter) - set_source_files_properties(${ONNXRUNTIME_ROOT}/hosting/http/predict_request_handler.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter) - set_source_files_properties(${ONNXRUNTIME_ROOT}/hosting/executor.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter) - set_source_files_properties(${ONNXRUNTIME_ROOT}/hosting/converter.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter) - set_source_files_properties(${ONNXRUNTIME_ROOT}/hosting/util.cc PROPERTIES COMPILE_FLAGS -Wno-unused-parameter) - endif() -endif() - -file(GLOB_RECURSE onnxruntime_hosting_http_core_lib_srcs - "${ONNXRUNTIME_ROOT}/hosting/http/core/*.cc" - ) - -file(GLOB_RECURSE onnxruntime_hosting_srcs - "${ONNXRUNTIME_ROOT}/hosting/main.cc" -) - -# HTTP core library -add_library(onnxruntime_hosting_http_core_lib STATIC - ${onnxruntime_hosting_http_core_lib_srcs}) -target_include_directories(onnxruntime_hosting_http_core_lib - PUBLIC - ${ONNXRUNTIME_ROOT}/hosting/http/core - ${Boost_INCLUDE_DIR} - ${re2_src} -) -add_dependencies(onnxruntime_hosting_http_core_lib Boost) -target_link_libraries(onnxruntime_hosting_http_core_lib PRIVATE - ${Boost_LIBRARIES} -) - -# Hosting library -add_library(onnxruntime_hosting_lib ${onnxruntime_hosting_lib_srcs}) -onnxruntime_add_include_to_target(onnxruntime_hosting_lib gsl onnx_proto hosting_proto) -target_include_directories(onnxruntime_hosting_lib PRIVATE - ${ONNXRUNTIME_ROOT} - ${CMAKE_CURRENT_BINARY_DIR}/onnx - ${ONNXRUNTIME_ROOT}/hosting - ${ONNXRUNTIME_ROOT}/hosting/http - PUBLIC - ${Boost_INCLUDE_DIR} - ${re2_src} -) - -target_link_libraries(onnxruntime_hosting_lib PRIVATE - hosting_proto - ${Boost_LIBRARIES} - onnxruntime_hosting_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_hosting_srcs} ${onnxruntime_hosting_lib_srcs} ${onnxruntime_hosting_lib}) - -# Hosting Application -add_executable(${HOSTING_APP_NAME} ${onnxruntime_hosting_srcs}) -add_dependencies(${HOSTING_APP_NAME} onnx hosting_proto onnx_proto ${onnxruntime_EXTERNAL_DEPENDENCIES}) - -if(NOT WIN32) - if(HAS_UNUSED_PARAMETER) - set_source_files_properties("${ONNXRUNTIME_ROOT}/hosting/main.cc" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter) - endif() -endif() - -onnxruntime_add_include_to_target(${HOSTING_APP_NAME} onnxruntime_session onnxruntime_hosting_lib gsl onnx onnx_proto hosting_proto) - -target_include_directories(${HOSTING_APP_NAME} PRIVATE - ${ONNXRUNTIME_ROOT} - ${ONNXRUNTIME_ROOT}/hosting/http -) - -target_link_libraries(${HOSTING_APP_NAME} PRIVATE - onnxruntime_hosting_http_core_lib - onnxruntime_hosting_lib -) - diff --git a/cmake/onnxruntime_server.cmake b/cmake/onnxruntime_server.cmake new file mode 100644 index 0000000000000..f67df80e4da35 --- /dev/null +++ b/cmake/onnxruntime_server.cmake @@ -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 $ "${CMAKE_CURRENT_BINARY_DIR}/.." ${CMAKE_CURRENT_BINARY_DIR}/onnx) +target_compile_definitions(server_proto PUBLIC $) +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 +) + diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake index 04db354db3c90..73b5b48be5fa9 100644 --- a/cmake/onnxruntime_unittests.cmake +++ b/cmake/onnxruntime_unittests.cmake @@ -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) @@ -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 $/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} - $/hosting_test/ + ${onnxruntime_integration_test_server_src} + ${CMAKE_CURRENT_BINARY_DIR}/server_test/ COMMAND ${CMAKE_COMMAND} -E copy - $/*_pb2.py - $/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() diff --git a/docs/Hosting_Application_Usage.md b/docs/ONNX_Runtime_Server_Usage.md similarity index 88% rename from docs/Hosting_Application_Usage.md rename to docs/ONNX_Runtime_Server_Usage.md index a542ea32a46a9..ac23bbb83726a 100644 --- a/docs/Hosting_Application_Usage.md +++ b/docs/ONNX_Runtime_Server_Usage.md @@ -1,21 +1,21 @@ -

Note: Hosting Application is still in beta state. It's currently not ready for production environments.

+

Note: ONNX Runtime Server is still in beta state. It's currently not ready for production environments.

-# How to Use ONNX Hosting Application REST API for Prediction +# How to Use ONNX Runtime Server REST API for Prediction -ONNX Hosting provides a REST API for prediction. The goal of the project is to make it easy to "host" any ONNX model as a RESTful service. The CLI command to start the service is shown below: +ONNX Runtime Server provides a REST API for prediction. The goal of the project is to make it easy to "host" any ONNX model as a RESTful service. The CLI command to start the service is shown below: ``` -~./onnxruntime_hosting --help -ONNX Hosting: host an ONNX model for inferencing with ONNXRuntime +$ ./onnxruntime_server +the option '--model_path' is required but missing Allowed options: - -h [ --help ] Shows a help message and exits - --log_level arg (=info) Logging level. Allowed options (case - sensitive): verbose, info, warning, error, - fatal - -m [ --model_path ] arg Path to ONNX model - -a [ --address ] arg (=0.0.0.0) The base HTTP address - --http_port arg (=8001) HTTP port to listen to requests - --num_http_threads arg (=8) Number of http threads + -h [ --help ] Shows a help message and exits + --log_level arg (=info) Logging level. Allowed options (case sensitive): + verbose, info, warning, error, fatal + --model_path arg Path to ONNX model + --address arg (=0.0.0.0) The base HTTP address + --http_port arg (=8001) HTTP port to listen to requests + --num_http_threads arg (=<# of your cpu cores>) Number of http threads + ``` @@ -26,7 +26,7 @@ Note: The only mandatory argument for the program here is `model_path` To host an ONNX model as a REST API server, run: ``` -./onnxruntime_hosting -m /// +./onnxruntime_server --model_path /// ``` The prediction URL is in this format: @@ -44,7 +44,7 @@ An HTTP request can be a Protobuf message in two formats: binary or JSON. The HT * For `"Content-Type: application/json"`, the payload will be deserialized as JSON string in UTF-8 format * For `"Content-Type: application/vnd.google.protobuf"`, `"Content-Type: application/x-protobuf"` or `"Content-Type: application/octet-stream"`, the payload will be consumed as protobuf message directly. -The Protobuf definition can be found [here](https://github.com/Microsoft/onnxruntime/blob/master/onnxruntime/hosting/protobuf/predict.proto). +The Protobuf definition can be found [here](https://github.com/Microsoft/onnxruntime/blob/master/onnxruntime/server/protobuf/predict.proto). ## Inferencing diff --git a/onnxruntime/hosting/converter.cc b/onnxruntime/server/converter.cc similarity index 99% rename from onnxruntime/hosting/converter.cc rename to onnxruntime/server/converter.cc index 5b2852fe7bc1b..56fd51cd10c4c 100644 --- a/onnxruntime/hosting/converter.cc +++ b/onnxruntime/server/converter.cc @@ -17,7 +17,7 @@ #include "converter.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace protobufutil = google::protobuf::util; @@ -257,5 +257,5 @@ common::Status MLValueToTensorProto(const onnxruntime::MLValue& ml_value, bool u return common::Status::OK(); } -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/hosting/converter.h b/onnxruntime/server/converter.h similarity index 96% rename from onnxruntime/hosting/converter.h rename to onnxruntime/server/converter.h index bfa64cf9ca009..983c9f454596c 100644 --- a/onnxruntime/hosting/converter.h +++ b/onnxruntime/server/converter.h @@ -11,7 +11,7 @@ #include "predict.pb.h" namespace onnxruntime { -namespace hosting { +namespace server { onnx::TensorProto_DataType MLDataTypeToTensorProtoDataType(const onnxruntime::DataTypeImpl* cpp_type); @@ -25,5 +25,5 @@ common::Status MLValueToTensorProto(const onnxruntime::MLValue& ml_value, bool u std::unique_ptr logger, /* out */ onnx::TensorProto& tensor_proto); -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/environment.cc b/onnxruntime/server/environment.cc similarity index 74% rename from onnxruntime/hosting/environment.cc rename to onnxruntime/server/environment.cc index 51352b9f99346..5235cad266d8c 100644 --- a/onnxruntime/hosting/environment.cc +++ b/onnxruntime/server/environment.cc @@ -8,10 +8,10 @@ #include "log_sink.h" namespace onnxruntime { -namespace hosting { +namespace server { -HostingEnvironment::HostingEnvironment(logging::Severity severity) : severity_(severity), - logger_id_("HostingApp"), +ServerEnvironment::ServerEnvironment(logging::Severity severity) : severity_(severity), + logger_id_("ServerApp"), default_logging_manager_( std::unique_ptr{new LogSink{}}, severity, @@ -24,7 +24,7 @@ HostingEnvironment::HostingEnvironment(logging::Severity severity) : severity_(s session = std::make_unique(options_, &default_logging_manager_); } -common::Status HostingEnvironment::InitializeModel(const std::string& model_path) { +common::Status ServerEnvironment::InitializeModel(const std::string& model_path) { auto status = session->Load(model_path); if (!status.IsOK()) { return status; @@ -42,19 +42,19 @@ common::Status HostingEnvironment::InitializeModel(const std::string& model_path return common::Status::OK(); } -const std::vector& HostingEnvironment::GetModelOutputNames() const { +const std::vector& ServerEnvironment::GetModelOutputNames() const { return model_output_names_; } -const logging::Logger& HostingEnvironment::GetAppLogger() const { +const logging::Logger& ServerEnvironment::GetAppLogger() const { return default_logging_manager_.DefaultLogger(); } -logging::Severity HostingEnvironment::GetLogSeverity() const { +logging::Severity ServerEnvironment::GetLogSeverity() const { return severity_; } -std::unique_ptr HostingEnvironment::GetLogger(const std::string& id) { +std::unique_ptr ServerEnvironment::GetLogger(const std::string& id) { if (id.empty()) { LOGS(GetAppLogger(), WARNING) << "Request id is null or empty string"; } @@ -62,9 +62,9 @@ std::unique_ptr HostingEnvironment::GetLogger(const std::string return default_logging_manager_.CreateLogger(id, severity_, false); } -onnxruntime::InferenceSession* HostingEnvironment::GetSession() const { +onnxruntime::InferenceSession* ServerEnvironment::GetSession() const { return session.get(); } -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/environment.h b/onnxruntime/server/environment.h similarity index 82% rename from onnxruntime/hosting/environment.h rename to onnxruntime/server/environment.h index 011fc1336710f..4e0e408a7f20f 100644 --- a/onnxruntime/hosting/environment.h +++ b/onnxruntime/server/environment.h @@ -11,15 +11,15 @@ #include "core/session/inference_session.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace logging = logging; -class HostingEnvironment { +class ServerEnvironment { public: - explicit HostingEnvironment(logging::Severity severity); - ~HostingEnvironment() = default; - HostingEnvironment(const HostingEnvironment&) = delete; + explicit ServerEnvironment(logging::Severity severity); + ~ServerEnvironment() = default; + ServerEnvironment(const ServerEnvironment&) = delete; const logging::Logger& GetAppLogger() const; std::unique_ptr GetLogger(const std::string& id); @@ -41,5 +41,5 @@ class HostingEnvironment { std::vector model_output_names_; }; -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/executor.cc b/onnxruntime/server/executor.cc similarity index 94% rename from onnxruntime/hosting/executor.cc rename to onnxruntime/server/executor.cc index 0a3f26d215548..48535129b9028 100644 --- a/onnxruntime/hosting/executor.cc +++ b/onnxruntime/server/executor.cc @@ -20,7 +20,7 @@ #include "util.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace protobufutil = google::protobuf::util; @@ -51,7 +51,7 @@ protobufutil::Status Executor::SetMLValue(const onnx::TensorProto& input_tensor, return protobufutil::Status::OK; } -protobufutil::Status Executor::SetNameMLValueMap(onnxruntime::NameMLValMap& name_value_map, const onnxruntime::hosting::PredictRequest& request) { +protobufutil::Status Executor::SetNameMLValueMap(onnxruntime::NameMLValMap& name_value_map, const onnxruntime::server::PredictRequest& request) { auto logger = env_->GetLogger(request_id_); OrtAllocatorInfo* cpu_allocator_info = nullptr; @@ -84,8 +84,8 @@ protobufutil::Status Executor::SetNameMLValueMap(onnxruntime::NameMLValMap& name protobufutil::Status Executor::Predict(const std::string& model_name, const std::string& model_version, - onnxruntime::hosting::PredictRequest& request, - /* out */ onnxruntime::hosting::PredictResponse& response) { + onnxruntime::server::PredictRequest& request, + /* out */ onnxruntime::server::PredictResponse& response) { auto logger = env_->GetLogger(request_id_); // Convert PredictRequest to NameMLValMap @@ -144,5 +144,5 @@ protobufutil::Status Executor::Predict(const std::string& model_name, return protobufutil::Status::OK; } -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/hosting/executor.h b/onnxruntime/server/executor.h similarity index 75% rename from onnxruntime/hosting/executor.h rename to onnxruntime/server/executor.h index 17a0fb5ab8321..47aaa49b84d07 100644 --- a/onnxruntime/hosting/executor.h +++ b/onnxruntime/server/executor.h @@ -9,22 +9,22 @@ #include "predict.pb.h" namespace onnxruntime { -namespace hosting { +namespace server { class Executor { public: - Executor(HostingEnvironment* hosting_env, std::string request_id) : env_(hosting_env), + Executor(ServerEnvironment* server_env, std::string request_id) : env_(server_env), request_id_(std::move(request_id)), using_raw_data_(true) {} // Prediction method google::protobuf::util::Status Predict(const std::string& model_name, const std::string& model_version, - onnxruntime::hosting::PredictRequest& request, - /* out */ onnxruntime::hosting::PredictResponse& response); + onnxruntime::server::PredictRequest& request, + /* out */ onnxruntime::server::PredictResponse& response); private: - HostingEnvironment* env_; + ServerEnvironment* env_; const std::string request_id_; bool using_raw_data_; @@ -32,8 +32,8 @@ class Executor { OrtAllocatorInfo* cpu_allocator_info, /* out */ MLValue& ml_value); - google::protobuf::util::Status SetNameMLValueMap(onnxruntime::NameMLValMap& name_value_map, const onnxruntime::hosting::PredictRequest& request); + google::protobuf::util::Status SetNameMLValueMap(onnxruntime::NameMLValMap& name_value_map, const onnxruntime::server::PredictRequest& request); }; -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/core/context.h b/onnxruntime/server/http/core/context.h similarity index 96% rename from onnxruntime/hosting/http/core/context.h rename to onnxruntime/server/http/core/context.h index 63ad0ef009a10..b9598762fd5a5 100644 --- a/onnxruntime/hosting/http/core/context.h +++ b/onnxruntime/server/http/core/context.h @@ -16,7 +16,7 @@ #include namespace onnxruntime { -namespace hosting { +namespace server { namespace http = boost::beast::http; // from @@ -42,5 +42,5 @@ class HttpContext { HttpContext(const HttpContext&) = delete; }; -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/core/http_server.cc b/onnxruntime/server/http/core/http_server.cc similarity index 97% rename from onnxruntime/hosting/http/core/http_server.cc rename to onnxruntime/server/http/core/http_server.cc index 134e8a09d83a9..a7ae6f7cbe6c1 100644 --- a/onnxruntime/hosting/http/core/http_server.cc +++ b/onnxruntime/server/http/core/http_server.cc @@ -20,7 +20,7 @@ namespace net = boost::asio; // from using tcp = boost::asio::ip::tcp; // from namespace onnxruntime { -namespace hosting { +namespace server { App::App() { http_details.address = boost::asio::ip::make_address_v4("0.0.0.0"); @@ -84,5 +84,5 @@ App& App::Run() { ioc.run(); return *this; } -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/core/http_server.h b/onnxruntime/server/http/core/http_server.h similarity index 96% rename from onnxruntime/hosting/http/core/http_server.h rename to onnxruntime/server/http/core/http_server.h index e28d12939589c..505d93668cb47 100644 --- a/onnxruntime/hosting/http/core/http_server.h +++ b/onnxruntime/server/http/core/http_server.h @@ -17,7 +17,7 @@ #include "listener.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace http = beast::http; // from namespace net = boost::asio; // from @@ -49,5 +49,5 @@ class App { StartFn on_start_ = {}; Details http_details{}; }; -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/core/listener.cc b/onnxruntime/server/http/core/listener.cc similarity index 97% rename from onnxruntime/hosting/http/core/listener.cc rename to onnxruntime/server/http/core/listener.cc index c30b936119df2..93e2e4ac68eae 100644 --- a/onnxruntime/hosting/http/core/listener.cc +++ b/onnxruntime/server/http/core/listener.cc @@ -6,7 +6,7 @@ #include "util.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace net = boost::asio; // from using tcp = boost::asio::ip::tcp; // from @@ -78,5 +78,5 @@ void Listener::OnAccept(beast::error_code ec) { // Accept another connection DoAccept(); } -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/hosting/http/core/listener.h b/onnxruntime/server/http/core/listener.h similarity index 95% rename from onnxruntime/hosting/http/core/listener.h rename to onnxruntime/server/http/core/listener.h index 0415c0fb93c27..3295e6a448cb4 100644 --- a/onnxruntime/hosting/http/core/listener.h +++ b/onnxruntime/server/http/core/listener.h @@ -11,7 +11,7 @@ #include "util.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace net = boost::asio; // from using tcp = boost::asio::ip::tcp; // from @@ -39,6 +39,6 @@ class Listener : public std::enable_shared_from_this { void OnAccept(beast::error_code ec); }; -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/core/routes.cc b/onnxruntime/server/http/core/routes.cc similarity index 97% rename from onnxruntime/hosting/http/core/routes.cc rename to onnxruntime/server/http/core/routes.cc index af174c32096a3..5bb0878845b34 100644 --- a/onnxruntime/hosting/http/core/routes.cc +++ b/onnxruntime/server/http/core/routes.cc @@ -8,7 +8,7 @@ #include "routes.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace http = boost::beast::http; // from @@ -77,5 +77,5 @@ http::status Routes::ParseUrl(http::verb method, return http::status::ok; } -} //namespace hosting +} //namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/hosting/http/core/routes.h b/onnxruntime/server/http/core/routes.h similarity index 96% rename from onnxruntime/hosting/http/core/routes.h rename to onnxruntime/server/http/core/routes.h index 29a1064edf7b0..5681f2437d605 100644 --- a/onnxruntime/hosting/http/core/routes.h +++ b/onnxruntime/server/http/core/routes.h @@ -8,7 +8,7 @@ #include "context.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace http = boost::beast::http; // from @@ -36,6 +36,6 @@ class Routes { std::vector> get_fn_table; }; -} //namespace hosting +} //namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/core/session.cc b/onnxruntime/server/http/core/session.cc similarity index 99% rename from onnxruntime/hosting/http/core/session.cc rename to onnxruntime/server/http/core/session.cc index 6fe9eec742d6f..e7463ade65226 100644 --- a/onnxruntime/hosting/http/core/session.cc +++ b/onnxruntime/server/http/core/session.cc @@ -4,7 +4,7 @@ #include "session.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace net = boost::asio; // from namespace beast = boost::beast; // from @@ -148,5 +148,5 @@ http::status HttpSession::ExecuteUserFunction(HttpContext& context) { return http::status::ok; } -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/hosting/http/core/session.h b/onnxruntime/server/http/core/session.h similarity index 98% rename from onnxruntime/hosting/http/core/session.h rename to onnxruntime/server/http/core/session.h index a3827c52ba9c4..c1c8dd5f3c0a6 100644 --- a/onnxruntime/hosting/http/core/session.h +++ b/onnxruntime/server/http/core/session.h @@ -15,7 +15,7 @@ #include "util.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace net = boost::asio; // from namespace beast = boost::beast; // from @@ -74,6 +74,6 @@ class HttpSession : public std::enable_shared_from_this { void DoClose(); }; -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/core/util.cc b/onnxruntime/server/http/core/util.cc similarity index 90% rename from onnxruntime/hosting/http/core/util.cc rename to onnxruntime/server/http/core/util.cc index eb23a067bac76..a5680b800c4e4 100644 --- a/onnxruntime/hosting/http/core/util.cc +++ b/onnxruntime/server/http/core/util.cc @@ -9,12 +9,12 @@ #include "util.h" namespace onnxruntime { -namespace hosting { +namespace server { // Report a failure void ErrorHandling(beast::error_code ec, char const* what) { std::cerr << what << " failed: " << ec.value() << " : " << ec.message() << "\n"; } -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/hosting/http/core/util.h b/onnxruntime/server/http/core/util.h similarity index 90% rename from onnxruntime/hosting/http/core/util.h rename to onnxruntime/server/http/core/util.h index 5d73000c2a866..54faea9629ff8 100644 --- a/onnxruntime/hosting/http/core/util.h +++ b/onnxruntime/server/http/core/util.h @@ -9,13 +9,13 @@ #include "context.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace beast = boost::beast; // from // Report a failure void ErrorHandling(beast::error_code ec, char const* what); -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/json_handling.cc b/onnxruntime/server/http/json_handling.cc similarity index 88% rename from onnxruntime/hosting/http/json_handling.cc rename to onnxruntime/server/http/json_handling.cc index caae91b00a5b6..6bc46b7878338 100644 --- a/onnxruntime/hosting/http/json_handling.cc +++ b/onnxruntime/server/http/json_handling.cc @@ -13,9 +13,9 @@ namespace protobufutil = google::protobuf::util; namespace onnxruntime { -namespace hosting { +namespace server { -protobufutil::Status GetRequestFromJson(const std::string& json_string, /* out */ onnxruntime::hosting::PredictRequest& request) { +protobufutil::Status GetRequestFromJson(const std::string& json_string, /* out */ onnxruntime::server::PredictRequest& request) { protobufutil::JsonParseOptions options; options.ignore_unknown_fields = true; @@ -23,7 +23,7 @@ protobufutil::Status GetRequestFromJson(const std::string& json_string, /* out * return result; } -protobufutil::Status GenerateResponseInJson(const onnxruntime::hosting::PredictResponse& response, /* out */ std::string& json_string) { +protobufutil::Status GenerateResponseInJson(const onnxruntime::server::PredictResponse& response, /* out */ std::string& json_string) { protobufutil::JsonPrintOptions options; options.add_whitespace = false; options.always_print_primitive_fields = false; @@ -62,5 +62,5 @@ std::string escape_string(const std::string& message) { return o.str(); } -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/hosting/http/json_handling.h b/onnxruntime/server/http/json_handling.h similarity index 85% rename from onnxruntime/hosting/http/json_handling.h rename to onnxruntime/server/http/json_handling.h index ce6c7f9e9cbeb..1e3d8f7239db1 100644 --- a/onnxruntime/hosting/http/json_handling.h +++ b/onnxruntime/server/http/json_handling.h @@ -9,18 +9,18 @@ #include "predict.pb.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace http = boost::beast::http; // Deserialize Json input to PredictRequest. // Unknown fields in the json file will be ignored. -google::protobuf::util::Status GetRequestFromJson(const std::string& json_string, /* out */ onnxruntime::hosting::PredictRequest& request); +google::protobuf::util::Status GetRequestFromJson(const std::string& json_string, /* out */ onnxruntime::server::PredictRequest& request); // Serialize PredictResponse to json string // 1. Proto3 primitive fields with default values will be omitted in JSON output. Eg. int32 field with value 0 will be omitted // 2. Enums will be printed as string, not int, to improve readability -google::protobuf::util::Status GenerateResponseInJson(const onnxruntime::hosting::PredictResponse& response, /* out */ std::string& json_string); +google::protobuf::util::Status GenerateResponseInJson(const onnxruntime::server::PredictResponse& response, /* out */ std::string& json_string); // Constructs JSON error message from error code object and error message std::string CreateJsonError(http::status error_code, const std::string& error_message); @@ -29,6 +29,6 @@ std::string CreateJsonError(http::status error_code, const std::string& error_me // Mostly taken from here: https://stackoverflow.com/questions/7724448/simple-json-string-escape-for-c/33799784#33799784 std::string escape_string(const std::string& message); -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/predict_request_handler.cc b/onnxruntime/server/http/predict_request_handler.cc similarity index 98% rename from onnxruntime/hosting/http/predict_request_handler.cc rename to onnxruntime/server/http/predict_request_handler.cc index f3fadd32c53db..32d6443744e3d 100644 --- a/onnxruntime/hosting/http/predict_request_handler.cc +++ b/onnxruntime/server/http/predict_request_handler.cc @@ -10,7 +10,7 @@ #include "util.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace protobufutil = google::protobuf::util; @@ -35,7 +35,7 @@ void Predict(const std::string& name, const std::string& version, const std::string& action, /* in, out */ HttpContext& context, - std::shared_ptr env) { + std::shared_ptr env) { auto logger = env->GetLogger(context.request_id); LOGS(*logger, INFO) << "Model Name: " << name << ", Version: " << version << ", Action: " << action; @@ -130,5 +130,5 @@ static bool ParseRequestPayload(const HttpContext& context, SupportedContentType return true; } -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/predict_request_handler.h b/onnxruntime/server/http/predict_request_handler.h similarity index 84% rename from onnxruntime/hosting/http/predict_request_handler.h rename to onnxruntime/server/http/predict_request_handler.h index 0b1cce1216f36..8fe0d7f74d263 100644 --- a/onnxruntime/hosting/http/predict_request_handler.h +++ b/onnxruntime/server/http/predict_request_handler.h @@ -5,7 +5,7 @@ #include "json_handling.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace beast = boost::beast; namespace http = beast::http; @@ -17,7 +17,7 @@ void Predict(const std::string& name, const std::string& version, const std::string& action, /* in, out */ HttpContext& context, - std::shared_ptr env); + std::shared_ptr env); -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/http/util.cc b/onnxruntime/server/http/util.cc similarity index 98% rename from onnxruntime/hosting/http/util.cc rename to onnxruntime/server/http/util.cc index 0b9d2a704e7e0..61986291f444a 100644 --- a/onnxruntime/hosting/http/util.cc +++ b/onnxruntime/server/http/util.cc @@ -11,7 +11,7 @@ namespace protobufutil = google::protobuf::util; namespace onnxruntime { -namespace hosting { +namespace server { static std::unordered_set protobuf_mime_types{ "application/octet-stream", @@ -80,5 +80,5 @@ SupportedContentType GetResponseContentType(const HttpContext& context) { return SupportedContentType::Unknown; } -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/hosting/http/util.h b/onnxruntime/server/http/util.h similarity index 92% rename from onnxruntime/hosting/http/util.h rename to onnxruntime/server/http/util.h index 469d40e4bda1a..ba38b3976a1cb 100644 --- a/onnxruntime/hosting/http/util.h +++ b/onnxruntime/server/http/util.h @@ -7,10 +7,10 @@ #include #include -#include "hosting/http/core/context.h" +#include "server/http/core/context.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace beast = boost::beast; // from @@ -31,5 +31,5 @@ SupportedContentType GetRequestContentType(const HttpContext& context); // Currently we only support three types of response content type: */*, application/json and application/octet-stream SupportedContentType GetResponseContentType(const HttpContext& context); -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/log_sink.h b/onnxruntime/server/log_sink.h similarity index 90% rename from onnxruntime/hosting/log_sink.h rename to onnxruntime/server/log_sink.h index b177fec6052fc..70df47f72c0a7 100644 --- a/onnxruntime/hosting/log_sink.h +++ b/onnxruntime/server/log_sink.h @@ -8,13 +8,13 @@ #include "core/common/logging/sinks/ostream_sink.h" namespace onnxruntime { -namespace hosting { +namespace server { class LogSink : public onnxruntime::logging::OStreamSink { public: LogSink() : OStreamSink(std::cout, /*flush*/ true) { } }; -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/main.cc b/onnxruntime/server/main.cc similarity index 84% rename from onnxruntime/hosting/main.cc rename to onnxruntime/server/main.cc index 88a32942852e8..ac4891566b1d5 100644 --- a/onnxruntime/hosting/main.cc +++ b/onnxruntime/server/main.cc @@ -8,19 +8,19 @@ namespace beast = boost::beast; namespace http = beast::http; -namespace hosting = onnxruntime::hosting; +namespace server = onnxruntime::server; int main(int argc, char* argv[]) { - hosting::ServerConfiguration config{}; + server::ServerConfiguration config{}; auto res = config.ParseInput(argc, argv); - if (res == hosting::Result::ExitSuccess) { + if (res == server::Result::ExitSuccess) { exit(EXIT_SUCCESS); - } else if (res == hosting::Result::ExitFailure) { + } else if (res == server::Result::ExitFailure) { exit(EXIT_FAILURE); } - auto env = std::make_shared(config.logging_level); + auto env = std::make_shared(config.logging_level); auto logger = env->GetAppLogger(); LOGS(logger, VERBOSE) << "Logging manager initialized."; LOGS(logger, INFO) << "Model path: " << config.model_path; @@ -42,7 +42,7 @@ int main(int argc, char* argv[]) { } auto const boost_address = boost::asio::ip::make_address(config.address); - hosting::App app{}; + server::App app{}; app.RegisterStartup( [env](const auto& details) -> void { @@ -63,13 +63,13 @@ int main(int argc, char* argv[]) { if (!context.client_request_id.empty()) { context.response.insert("x-ms-client-request-id", (context).client_request_id); } - context.response.body() = hosting::CreateJsonError(context.error_code, context.error_message); + context.response.body() = server::CreateJsonError(context.error_code, context.error_message); }); app.RegisterPost( R"(/v1/models/([^/:]+)(?:/versions/(\d+))?:(classify|regress|predict))", [env](const auto& name, const auto& version, const auto& action, auto& context) -> void { - hosting::Predict(name, version, action, context, env); + server::Predict(name, version, action, context, env); }); app.Bind(boost_address, config.http_port) diff --git a/onnxruntime/hosting/protobuf/onnx-ml.proto b/onnxruntime/server/protobuf/onnx-ml.proto similarity index 100% rename from onnxruntime/hosting/protobuf/onnx-ml.proto rename to onnxruntime/server/protobuf/onnx-ml.proto diff --git a/onnxruntime/hosting/protobuf/predict.proto b/onnxruntime/server/protobuf/predict.proto similarity index 96% rename from onnxruntime/hosting/protobuf/predict.proto rename to onnxruntime/server/protobuf/predict.proto index 33029ad8a600c..21b04386353eb 100644 --- a/onnxruntime/hosting/protobuf/predict.proto +++ b/onnxruntime/server/protobuf/predict.proto @@ -2,7 +2,7 @@ syntax = "proto3"; import "onnx-ml.proto"; -package onnxruntime.hosting; +package onnxruntime.server; // PredictRequest specifies how inputs are mapped to tensors // and how outputs are filtered before returning to user. diff --git a/onnxruntime/hosting/server_configuration.h b/onnxruntime/server/server_configuration.h similarity index 97% rename from onnxruntime/hosting/server_configuration.h rename to onnxruntime/server/server_configuration.h index d5b1ee459bc21..4ae9b58496da7 100644 --- a/onnxruntime/hosting/server_configuration.h +++ b/onnxruntime/server/server_configuration.h @@ -11,7 +11,7 @@ #include "core/common/logging/logging.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace po = boost::program_options; @@ -37,7 +37,7 @@ static std::unordered_map supported // Provides sane default values class ServerConfiguration { public: - const std::string full_desc = "ONNX Hosting: host an ONNX model with ONNX Runtime"; + const std::string full_desc = "ONNX Server: host an ONNX model with ONNX Runtime"; std::string model_path; std::string address = "0.0.0.0"; int http_port = 8001; @@ -127,5 +127,5 @@ class ServerConfiguration { } }; -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/util.cc b/onnxruntime/server/util.cc similarity index 97% rename from onnxruntime/hosting/util.cc rename to onnxruntime/server/util.cc index 47bc4f03cb183..579c2e81bcc3c 100644 --- a/onnxruntime/hosting/util.cc +++ b/onnxruntime/server/util.cc @@ -8,7 +8,7 @@ #include "util.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace protobufutil = google::protobuf::util; @@ -44,5 +44,5 @@ protobufutil::Status GenerateProtobufStatus(const onnxruntime::common::Status& o return protobufutil::Status(code, oss.str()); } -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/hosting/util.h b/onnxruntime/server/util.h similarity index 90% rename from onnxruntime/hosting/util.h rename to onnxruntime/server/util.h index ead9e866d6a8f..e46a3a13fac63 100644 --- a/onnxruntime/hosting/util.h +++ b/onnxruntime/server/util.h @@ -8,11 +8,11 @@ #include "core/common/status.h" namespace onnxruntime { -namespace hosting { +namespace server { // Generate protobuf status from ONNX Runtime status google::protobuf::util::Status GenerateProtobufStatus(const onnxruntime::common::Status& onnx_status, const std::string& message); -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/test/hosting/integration_tests/README.MD b/onnxruntime/test/hosting/integration_tests/README.MD deleted file mode 100644 index 2d308fe1425b2..0000000000000 --- a/onnxruntime/test/hosting/integration_tests/README.MD +++ /dev/null @@ -1,43 +0,0 @@ -# ONNX Runtime Hosting Application Integration Tests - -## Preparation - -Tests validation depends on protobuf generated *_pb2.py. So we need to have a sucessful hosting application build to have it generated in the build folder under `hosting_test` subfolder. The following instruction assume you are in the folder. Otherwise, tests will fail due to `ModuleNotFoundError`. - -## Functional Tests - -Functional test will be run when build with `--build_hosting --enable_hosting_tests`. To run it separately, here is the command line: - -```Bash -/usr/bin/python3 ./test_main.py -``` - -## Model Zoo Tests - -To run this set of tests, a prepared test data set need to be downloaded from [Azure Blob Storage](https://onnxhostingdev.blob.core.windows.net/testing/hosting_test_data_20190422.zip) and unzip to a folder, e.g. /home/foo/bar/model_zoo_test. It contains: - -* ONNX models from [ONNX Model Zoo](https://github.com/onnx/models) with opset 7/8/9. -* HTTP request json and protobuf files -* Expected response json and protobuf files - -If you only need the request and response data. Here is the [link](https://onnxhostingdev.blob.core.windows.net/testing/hosting_test_data_req_resp_only.zip) to download. - -To run the full model zoo tests, here is the command line: - -```Bash -/usr/bin/python3 ./model_zoo_tests.py -``` - -For example: - -```Bash -/usr/bin/python3 ./model_zoo_tests.py /some/where/hosting_app /home/foo/bar/model_zoo_test /home/foo/bar/model_zoo_test -``` - -If those models are in different folder but in the same structure as the test data, you could also do - -```Bash -/usr/bin/python3 ./model_zoo_tests.py /some/where/hosting_app /home/my/models/ /home/foo/bar/model_zoo_test/ -``` - -All tests are running in sequential order. \ No newline at end of file diff --git a/onnxruntime/test/server/integration_tests/README.MD b/onnxruntime/test/server/integration_tests/README.MD new file mode 100644 index 0000000000000..141d531d1a9bc --- /dev/null +++ b/onnxruntime/test/server/integration_tests/README.MD @@ -0,0 +1,43 @@ +# ONNX Runtime Server Integration Tests + +## Preparation + +Tests validation depends on protobuf generated *_pb2.py. So we need to have a sucessful server application build to have it generated in the build folder under `server_test` subfolder. The following instruction assume you are in the folder. Otherwise, tests will fail due to `ModuleNotFoundError`. + +## Functional Tests + +Functional test will be run when build with `--build_server --enable_server_tests`. To run it separately, here is the command line: + +```Bash +/usr/bin/python3 ./test_main.py +``` + +## Model Zoo Tests + +To run this set of tests, a prepared test data set need to be downloaded from [Azure Blob Storage](https://onnxserverdev.blob.core.windows.net/testing/server_test_data_20190422.zip) and unzip to a folder, e.g. /home/foo/bar/model_zoo_test. It contains: + +* ONNX models from [ONNX Model Zoo](https://github.com/onnx/models) with opset 7/8/9. +* HTTP request json and protobuf files +* Expected response json and protobuf files + +If you only need the request and response data. Here is the [link](https://onnxserverdev.blob.core.windows.net/testing/server_test_data_req_resp_only.zip) to download. + +To run the full model zoo tests, here is the command line: + +```Bash +/usr/bin/python3 ./model_zoo_tests.py +``` + +For example: + +```Bash +/usr/bin/python3 ./model_zoo_tests.py /some/where/server_app /home/foo/bar/model_zoo_test /home/foo/bar/model_zoo_test +``` + +If those models are in different folder but in the same structure as the test data, you could also do + +```Bash +/usr/bin/python3 ./model_zoo_tests.py /some/where/server_app /home/my/models/ /home/foo/bar/model_zoo_test/ +``` + +All tests are running in sequential order. \ No newline at end of file diff --git a/onnxruntime/test/hosting/integration_tests/function_tests.py b/onnxruntime/test/server/integration_tests/function_tests.py similarity index 88% rename from onnxruntime/test/hosting/integration_tests/function_tests.py rename to onnxruntime/test/server/integration_tests/function_tests.py index 76433cbfcb6f3..aabeb8bfc1ceb 100644 --- a/onnxruntime/test/hosting/integration_tests/function_tests.py +++ b/onnxruntime/test/server/integration_tests/function_tests.py @@ -17,28 +17,28 @@ class HttpJsonPayloadTests(unittest.TestCase): server_ip = '127.0.0.1' server_port = 54321 url_pattern = 'http://{0}:{1}/v1/models/{2}/versions/{3}:predict' - hosting_app_path = '' + server_app_path = '' test_data_path = '' model_path = '' log_level = 'verbose' - hosting_app_proc = None + server_app_proc = None wait_server_ready_in_seconds = 1 @classmethod def setUpClass(cls): - cmd = [cls.hosting_app_path, '--http_port', str(cls.server_port), '--model_path', os.path.join(cls.model_path, 'mnist.onnx'), '--log_level', cls.log_level] - print('Launching hosting app: [{0}]'.format(' '.join(cmd))) - cls.hosting_app_proc = subprocess.Popen(cmd) - print('Hosting app PID: {0}'.format(cls.hosting_app_proc.pid)) + cmd = [cls.server_app_path, '--http_port', str(cls.server_port), '--model_path', os.path.join(cls.model_path, 'mnist.onnx'), '--log_level', cls.log_level] + print('Launching server app: [{0}]'.format(' '.join(cmd))) + cls.server_app_proc = subprocess.Popen(cmd) + print('Server app PID: {0}'.format(cls.server_app_proc.pid)) print('Sleep {0} second(s) to wait for server initialization'.format(cls.wait_server_ready_in_seconds)) time.sleep(cls.wait_server_ready_in_seconds) @classmethod def tearDownClass(cls): - print('Shutdown hosting app') - cls.hosting_app_proc.kill() - print('PID {0} has been killed: {1}'.format(cls.hosting_app_proc.pid, test_util.is_process_killed(cls.hosting_app_proc.pid))) + print('Shutdown server app') + cls.server_app_proc.kill() + print('PID {0} has been killed: {1}'.format(cls.server_app_proc.pid, test_util.is_process_killed(cls.server_app_proc.pid))) def test_mnist_happy_path(self): @@ -193,28 +193,28 @@ class HttpProtobufPayloadTests(unittest.TestCase): server_ip = '127.0.0.1' server_port = 54321 url_pattern = 'http://{0}:{1}/v1/models/{2}/versions/{3}:predict' - hosting_app_path = '' + server_app_path = '' test_data_path = '' model_path = '' log_level = 'verbose' - hosting_app_proc = None + server_app_proc = None wait_server_ready_in_seconds = 1 @classmethod def setUpClass(cls): - cmd = [cls.hosting_app_path, '--http_port', str(cls.server_port), '--model_path', os.path.join(cls.model_path, 'mnist.onnx'), '--log_level', cls.log_level] - print('Launching hosting app: [{0}]'.format(' '.join(cmd))) - cls.hosting_app_proc = subprocess.Popen(cmd) - print('Hosting app PID: {0}'.format(cls.hosting_app_proc.pid)) + cmd = [cls.server_app_path, '--http_port', str(cls.server_port), '--model_path', os.path.join(cls.model_path, 'mnist.onnx'), '--log_level', cls.log_level] + print('Launching server app: [{0}]'.format(' '.join(cmd))) + cls.server_app_proc = subprocess.Popen(cmd) + print('Server app PID: {0}'.format(cls.server_app_proc.pid)) print('Sleep {0} second(s) to wait for server initialization'.format(cls.wait_server_ready_in_seconds)) time.sleep(cls.wait_server_ready_in_seconds) @classmethod def tearDownClass(cls): - print('Shutdown hosting app') - cls.hosting_app_proc.kill() - print('PID {0} has been killed: {1}'.format(cls.hosting_app_proc.pid, test_util.is_process_killed(cls.hosting_app_proc.pid))) + print('Shutdown server app') + cls.server_app_proc.kill() + print('PID {0} has been killed: {1}'.format(cls.server_app_proc.pid, test_util.is_process_killed(cls.server_app_proc.pid))) def test_mnist_happy_path(self): @@ -321,28 +321,28 @@ def test_any_accept_header(self): class HttpEndpointTests(unittest.TestCase): server_ip = '127.0.0.1' server_port = 54321 - hosting_app_path = '' + server_app_path = '' test_data_path = '' model_path = '' log_level = 'verbose' - hosting_app_proc = None + server_app_proc = None wait_server_ready_in_seconds = 1 @classmethod def setUpClass(cls): - cmd = [cls.hosting_app_path, '--http_port', str(cls.server_port), '--model_path', os.path.join(cls.model_path, 'mnist.onnx'), '--log_level', cls.log_level] - print('Launching hosting app: [{0}]'.format(' '.join(cmd))) - cls.hosting_app_proc = subprocess.Popen(cmd) - print('Hosting app PID: {0}'.format(cls.hosting_app_proc.pid)) + cmd = [cls.server_app_path, '--http_port', str(cls.server_port), '--model_path', os.path.join(cls.model_path, 'mnist.onnx'), '--log_level', cls.log_level] + print('Launching server app: [{0}]'.format(' '.join(cmd))) + cls.server_app_proc = subprocess.Popen(cmd) + print('Server app PID: {0}'.format(cls.server_app_proc.pid)) print('Sleep {0} second(s) to wait for server initialization'.format(cls.wait_server_ready_in_seconds)) time.sleep(cls.wait_server_ready_in_seconds) @classmethod def tearDownClass(cls): - print('Shutdown hosting app') - cls.hosting_app_proc.kill() - print('PID {0} has been killed: {1}'.format(cls.hosting_app_proc.pid, test_util.is_process_killed(cls.hosting_app_proc.pid))) + print('Shutdown server app') + cls.server_app_proc.kill() + print('PID {0} has been killed: {1}'.format(cls.server_app_proc.pid, test_util.is_process_killed(cls.server_app_proc.pid))) def test_health_endpoint(self): diff --git a/onnxruntime/test/hosting/integration_tests/model_zoo_data_prep.py b/onnxruntime/test/server/integration_tests/model_zoo_data_prep.py similarity index 100% rename from onnxruntime/test/hosting/integration_tests/model_zoo_data_prep.py rename to onnxruntime/test/server/integration_tests/model_zoo_data_prep.py diff --git a/onnxruntime/test/hosting/integration_tests/model_zoo_tests.py b/onnxruntime/test/server/integration_tests/model_zoo_tests.py similarity index 88% rename from onnxruntime/test/hosting/integration_tests/model_zoo_tests.py rename to onnxruntime/test/server/integration_tests/model_zoo_tests.py index 95f2e0e9a7438..c47a9c50b030d 100644 --- a/onnxruntime/test/hosting/integration_tests/model_zoo_tests.py +++ b/onnxruntime/test/server/integration_tests/model_zoo_tests.py @@ -11,7 +11,7 @@ class ModelZooTests(unittest.TestCase): server_ip = '127.0.0.1' server_port = 54321 url_pattern = 'http://{0}:{1}/v1/models/{2}/versions/{3}:predict' - hosting_app_path = '' # Required + server_app_path = '' # Required log_level = 'verbose' server_ready_in_seconds = 10 server_off_in_seconds = 100 @@ -55,11 +55,11 @@ def test_models_from_model_zoo(self): self.server_port = random.randint(30000, 40000) for model_path, data_paths in model_data_map.items(): - hosting_app_proc = None + server_app_proc = None try: - cmd = [self.hosting_app_path, '--http_port', str(self.server_port), '--model_path', os.path.join(model_path, 'model.onnx'), '--log_level', self.log_level] + cmd = [self.server_app_path, '--http_port', str(self.server_port), '--model_path', os.path.join(model_path, 'model.onnx'), '--log_level', self.log_level] test_util.test_log(cmd) - hosting_app_proc = test_util.launch_hosting_app(cmd, self.server_ip, self.server_port, self.server_ready_in_seconds) + server_app_proc = test_util.launch_server_app(cmd, self.server_ip, self.server_port, self.server_ready_in_seconds) test_util.test_log('[{0}] Run tests...'.format(model_path)) for test in data_paths: @@ -79,7 +79,7 @@ def test_models_from_model_zoo(self): resp = test_util.make_http_request(url, pb_request_headers, request_payload) test_util.pb_response_validation(self, resp, os.path.join(test, 'response.pb')) finally: - test_util.shutdown_hosting_app(hosting_app_proc, self.server_off_in_seconds) + test_util.shutdown_server_app(server_app_proc, self.server_off_in_seconds) if __name__ == '__main__': @@ -89,7 +89,7 @@ def test_models_from_model_zoo(self): test_suites = [] for tests in test_classes: - tests.hosting_app_path = sys.argv[1] + tests.server_app_path = sys.argv[1] tests.model_zoo_model_path = sys.argv[2] tests.model_zoo_test_data_path = sys.argv[3] diff --git a/onnxruntime/test/hosting/integration_tests/test_main.py b/onnxruntime/test/server/integration_tests/test_main.py similarity index 94% rename from onnxruntime/test/hosting/integration_tests/test_main.py rename to onnxruntime/test/server/integration_tests/test_main.py index 5e34768a3f8ef..83ff585fb5f78 100644 --- a/onnxruntime/test/hosting/integration_tests/test_main.py +++ b/onnxruntime/test/server/integration_tests/test_main.py @@ -13,7 +13,7 @@ test_suites = [] for tests in test_classes: - tests.hosting_app_path = sys.argv[1] + tests.server_app_path = sys.argv[1] tests.model_path = sys.argv[2] tests.test_data_path = sys.argv[3] tests.server_port = random.randint(30000, 50000) diff --git a/onnxruntime/test/hosting/integration_tests/test_util.py b/onnxruntime/test/server/integration_tests/test_util.py similarity index 87% rename from onnxruntime/test/hosting/integration_tests/test_util.py rename to onnxruntime/test/server/integration_tests/test_util.py index de1a926f41f3a..60840a873012b 100644 --- a/onnxruntime/test/hosting/integration_tests/test_util.py +++ b/onnxruntime/test/server/integration_tests/test_util.py @@ -70,24 +70,24 @@ def wait_service_up(server, port, timeout=1): return True -def launch_hosting_app(cmd, server_ip, server_port, wait_server_ready_in_seconds): - test_log('Launching hosting app: [{0}]'.format(' '.join(cmd))) - hosting_app_proc = subprocess.Popen(cmd) - test_log('Hosting app PID: {0}'.format(hosting_app_proc.pid)) +def launch_server_app(cmd, server_ip, server_port, wait_server_ready_in_seconds): + test_log('Launching server app: [{0}]'.format(' '.join(cmd))) + server_app_proc = subprocess.Popen(cmd) + test_log('Server app PID: {0}'.format(server_app_proc.pid)) test_log('Wait up to {0} second(s) for server initialization'.format(wait_server_ready_in_seconds)) wait_service_up(server_ip, server_port, wait_server_ready_in_seconds) - return hosting_app_proc + return server_app_proc -def shutdown_hosting_app(hosting_app_proc, wait_for_server_off_in_seconds): - if hosting_app_proc is not None: - test_log('Shutdown hosting app') - hosting_app_proc.kill() +def shutdown_server_app(server_app_proc, wait_for_server_off_in_seconds): + if server_app_proc is not None: + test_log('Shutdown server app') + server_app_proc.kill() - while not is_process_killed(hosting_app_proc.pid): - hosting_app_proc.wait(timeout=wait_for_server_off_in_seconds) - test_log('PID {0} has been killed: {1}'.format(hosting_app_proc.pid, is_process_killed(hosting_app_proc.pid))) + while not is_process_killed(server_app_proc.pid): + server_app_proc.wait(timeout=wait_for_server_off_in_seconds) + test_log('PID {0} has been killed: {1}'.format(server_app_proc.pid, is_process_killed(server_app_proc.pid))) # Additional sleep to make sure the resource has been freed. time.sleep(1) diff --git a/onnxruntime/test/hosting/unit_tests/converter_tests.cc b/onnxruntime/test/server/unit_tests/converter_tests.cc similarity index 88% rename from onnxruntime/test/hosting/unit_tests/converter_tests.cc rename to onnxruntime/test/server/unit_tests/converter_tests.cc index a470cc12e6258..e5f2d9642f2f6 100644 --- a/onnxruntime/test/hosting/unit_tests/converter_tests.cc +++ b/onnxruntime/test/server/unit_tests/converter_tests.cc @@ -8,10 +8,10 @@ #include "core/framework/allocatormgr.h" #include "test/framework/test_utils.h" #include "test/test_environment.h" -#include "hosting/converter.h" +#include "server/converter.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace test { void CreateMLValueBool(AllocatorPtr alloc, const std::vector& dims, const bool* value, MLValue* p_mlvalue); @@ -26,63 +26,63 @@ TEST(MLDataTypeToTensorProtoDataTypeTests, MLDataTypeToTensorProtoDataTypeTests) auto logger = std::make_unique(::onnxruntime::test::DefaultLoggingManager().DefaultLogger()); MLDataType ml_data_type = DataTypeImpl::GetType(); - onnx::TensorProto_DataType result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + onnx::TensorProto_DataType result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_FLOAT); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_FLOAT16); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_BFLOAT16); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_DOUBLE); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_UINT8); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_INT8); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_UINT16); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_INT16); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_UINT32); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_INT32); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_UINT64); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_INT64); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_STRING); ml_data_type = DataTypeImpl::GetType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_BOOL); ml_data_type = DataTypeImpl::GetTensorType(); - result = onnxruntime::hosting::MLDataTypeToTensorProtoDataType(ml_data_type); + result = onnxruntime::server::MLDataTypeToTensorProtoDataType(ml_data_type); EXPECT_EQ(result, onnx::TensorProto_DataType_UNDEFINED); } @@ -95,7 +95,7 @@ TEST(MLValueToTensorProtoTests, FloatToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -134,7 +134,7 @@ TEST(MLValueToTensorProtoTests, FloatToFloatData) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -169,7 +169,7 @@ TEST(MLValueToTensorProtoTests, Int32ToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -208,7 +208,7 @@ TEST(MLValueToTensorProtoTests, Int32ToInt32Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -243,7 +243,7 @@ TEST(MLValueToTensorProtoTests, UInt8ToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -282,7 +282,7 @@ TEST(MLValueToTensorProtoTests, UInt8ToInt32Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -319,7 +319,7 @@ TEST(MLValueToTensorProtoTests, Int8ToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -358,7 +358,7 @@ TEST(MLValueToTensorProtoTests, Int8ToInt32Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -395,7 +395,7 @@ TEST(MLValueToTensorProtoTests, UInt16ToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -434,7 +434,7 @@ TEST(MLValueToTensorProtoTests, UInt16ToInt32Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -471,7 +471,7 @@ TEST(MLValueToTensorProtoTests, Int16ToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -510,7 +510,7 @@ TEST(MLValueToTensorProtoTests, Int16ToInt32Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -547,7 +547,7 @@ TEST(MLValueToTensorProtoTests, BoolToRaw) { CreateMLValueBool(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -586,7 +586,7 @@ TEST(MLValueToTensorProtoTests, BoolToInt32Data) { CreateMLValueBool(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -629,7 +629,7 @@ TEST(MLValueToTensorProtoTests, Float16ToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -674,7 +674,7 @@ TEST(MLValueToTensorProtoTests, FloatToInt32Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -717,7 +717,7 @@ TEST(MLValueToTensorProtoTests, BFloat16ToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -762,7 +762,7 @@ TEST(MLValueToTensorProtoTests, BFloatToInt32Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -805,7 +805,7 @@ TEST(MLValueToTensorProtoTests, StringToStringData) { } onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -841,7 +841,7 @@ TEST(MLValueToTensorProtoTests, Int64ToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -880,7 +880,7 @@ TEST(MLValueToTensorProtoTests, Int64ToInt64Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -915,7 +915,7 @@ TEST(MLValueToTensorProtoTests, UInt32ToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -954,7 +954,7 @@ TEST(MLValueToTensorProtoTests, UInt32ToUint64Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -992,7 +992,7 @@ TEST(MLValueToTensorProtoTests, UInt64ToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -1031,7 +1031,7 @@ TEST(MLValueToTensorProtoTests, UInt64ToInt64Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -1066,7 +1066,7 @@ TEST(MLValueToTensorProtoTests, DoubleToRaw) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ true, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -1105,7 +1105,7 @@ TEST(MLValueToTensorProtoTests, DoubleToInt64Data) { onnxruntime::test::CreateMLValue(TestCPUExecutionProvider()->GetAllocator(0, OrtMemTypeDefault), dims_mul_x, values_mul_x, &ml_value); onnx::TensorProto tp; - common::Status status = onnxruntime::hosting::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); + common::Status status = onnxruntime::server::MLValueToTensorProto(ml_value, /* using_raw_data */ false, std::move(logger), tp); EXPECT_TRUE(status.IsOK()); // Verify data type @@ -1147,5 +1147,5 @@ void CreateMLValueBool(AllocatorPtr alloc, } } // namespace test -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/test/hosting/unit_tests/http_routes_tests.cc b/onnxruntime/test/server/unit_tests/http_routes_tests.cc similarity index 98% rename from onnxruntime/test/hosting/unit_tests/http_routes_tests.cc rename to onnxruntime/test/server/unit_tests/http_routes_tests.cc index 9acc32adce9c9..dbb955050165c 100644 --- a/onnxruntime/test/hosting/unit_tests/http_routes_tests.cc +++ b/onnxruntime/test/server/unit_tests/http_routes_tests.cc @@ -4,10 +4,10 @@ #include #include "gtest/gtest.h" -#include "hosting/http/core/routes.h" +#include "server/http/core/routes.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace test { using test_data = std::tuple; @@ -105,5 +105,5 @@ void run_route(const std::string& pattern, http::verb method, const std::vector< } } // namespace test -} // namespace hosting +} // namespace server } // namespace onnxruntime diff --git a/onnxruntime/test/hosting/unit_tests/json_handling_tests.cc b/onnxruntime/test/server/unit_tests/json_handling_tests.cc similarity index 93% rename from onnxruntime/test/hosting/unit_tests/json_handling_tests.cc rename to onnxruntime/test/server/unit_tests/json_handling_tests.cc index 3bb62a3945eb7..0bd2d16e45795 100644 --- a/onnxruntime/test/hosting/unit_tests/json_handling_tests.cc +++ b/onnxruntime/test/server/unit_tests/json_handling_tests.cc @@ -7,33 +7,33 @@ #include "gtest/gtest.h" #include "predict.pb.h" -#include "hosting/http/json_handling.h" +#include "server/http/json_handling.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace test { namespace protobufutil = google::protobuf::util; TEST(JsonDeserializationTests, HappyPath) { std::string input_json = R"({"inputs":{"Input3":{"dims":["1","1","28","28"],"dataType":1,"rawData":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAPwAAQEAAAAAAAAAAAAAAgEAAAABAAAAAAAAAMEEAAAAAAAAAAAAAYEEAAIA/AAAAAAAAmEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEEAAAAAAAAAAAAA4EAAAAAAAACAPwAAIEEAAAAAAAAAQAAAAEAAAIBBAAAAAAAAQEAAAEBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4EAAAABBAAAAAAAAAEEAAAAAAAAAAAAAAEEAAAAAAAAAAAAAmEEAAAAAAAAAAAAAgD8AAKhBAAAAAAAAgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAMEEAAAAAAAAAAAAAIEEAAEBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQQQAAAAAAAHBBAAAgQQAA0EEAAAhCAACIQQAAmkIAADV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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="}},"outputFilter":["Plus214_Output_0"]})"; - onnxruntime::hosting::PredictRequest request; - protobufutil::Status status = onnxruntime::hosting::GetRequestFromJson(input_json, request); + onnxruntime::server::PredictRequest request; + protobufutil::Status status = onnxruntime::server::GetRequestFromJson(input_json, request); EXPECT_EQ(protobufutil::error::OK, status.error_code()); } TEST(JsonDeserializationTests, WithUnknownField) { std::string input_json = R"({"foo": "bar","inputs":{"Input3":{"dims":["1","1","28","28"],"dataType":1,"rawData":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAPwAAQEAAAAAAAAAAAAAAgEAAAABAAAAAAAAAMEEAAAAAAAAAAAAAYEEAAIA/AAAAAAAAmEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEEAAAAAAAAAAAAA4EAAAAAAAACAPwAAIEEAAAAAAAAAQAAAAEAAAIBBAAAAAAAAQEAAAEBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4EAAAABBAAAAAAAAAEEAAAAAAAAAAAAAAEEAAAAAAAAAAAAAmEEAAAAAAAAAAAAAgD8AAKhBAAAAAAAAgEAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="}},"outputFilter":["Plus214_Output_0"]})"; - onnxruntime::hosting::PredictRequest request; - protobufutil::Status status = onnxruntime::hosting::GetRequestFromJson(input_json, request); + onnxruntime::server::PredictRequest request; + protobufutil::Status status = onnxruntime::server::GetRequestFromJson(input_json, request); EXPECT_EQ(protobufutil::error::OK, status.error_code()); } TEST(JsonDeserializationTests, InvalidData) { std::string input_json = R"({"inputs":{"Input3":{"dims":["1","1","28","28"],"dataType":1,"rawData":"hello"}},"outputFilter":["Plus214_Output_0"]})"; - onnxruntime::hosting::PredictRequest request; - protobufutil::Status status = onnxruntime::hosting::GetRequestFromJson(input_json, request); + onnxruntime::server::PredictRequest request; + protobufutil::Status status = onnxruntime::server::GetRequestFromJson(input_json, request); EXPECT_EQ(protobufutil::error::INVALID_ARGUMENT, status.error_code()); EXPECT_EQ("inputs[0].value.raw_data: invalid value \"hello\" for type TYPE_BYTES", status.error_message()); @@ -41,8 +41,8 @@ TEST(JsonDeserializationTests, InvalidData) { TEST(JsonDeserializationTests, InvalidJson) { std::string input_json = R"({inputs":{"Input3":{"dims":["1","1","28","28"],"dataType":1,"rawData":"hello"}},"outputFilter":["Plus214_Output_0"]})"; - onnxruntime::hosting::PredictRequest request; - protobufutil::Status status = onnxruntime::hosting::GetRequestFromJson(input_json, request); + onnxruntime::server::PredictRequest request; + protobufutil::Status status = onnxruntime::server::GetRequestFromJson(input_json, request); EXPECT_EQ(protobufutil::error::INVALID_ARGUMENT, status.error_code()); std::string errmsg = status.error_message(); @@ -50,9 +50,9 @@ TEST(JsonDeserializationTests, InvalidJson) { } TEST(JsonSerializationTests, HappyPath) { - std::string test_data = "testdata/hosting/response_0.pb"; + std::string test_data = "testdata/server/response_0.pb"; std::string expected_json_string = R"({"outputs":{"Plus214_Output_0":{"dims":["1","10"],"dataType":1,"rawData":"4+pzRFWuGsSMdM1F2gEnRFdRZcRZ9NDEURj0xBIzdsJOS0LEA/GzxA=="}}})"; - onnxruntime::hosting::PredictResponse response; + onnxruntime::server::PredictResponse response; std::string json_string; std::ifstream ifs(test_data, std::ios_base::in | std::ios_base::binary); @@ -62,7 +62,7 @@ TEST(JsonSerializationTests, HappyPath) { ifs.close(); EXPECT_TRUE(succeeded) << test_data << " is invalid" << std::endl; - protobufutil::Status status = onnxruntime::hosting::GenerateResponseInJson(response, json_string); + protobufutil::Status status = onnxruntime::server::GenerateResponseInJson(response, json_string); EXPECT_EQ(protobufutil::error::OK, status.error_code()); EXPECT_EQ(expected_json_string, json_string); @@ -124,5 +124,5 @@ TEST(JsonErrorMessageTests, MessageWithManyCarriageCharacters) { } } // namespace test -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/test/hosting/unit_tests/server_configuration_test.cc b/onnxruntime/test/server/unit_tests/server_configuration_test.cc similarity index 88% rename from onnxruntime/test/hosting/unit_tests/server_configuration_test.cc rename to onnxruntime/test/server/unit_tests/server_configuration_test.cc index bc2210374902b..77a979e27f593 100644 --- a/onnxruntime/test/hosting/unit_tests/server_configuration_test.cc +++ b/onnxruntime/test/server/unit_tests/server_configuration_test.cc @@ -4,10 +4,10 @@ #include "gtest/gtest.h" #include "gmock/gmock.h" -#include "hosting/server_configuration.h" +#include "server/server_configuration.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace test { TEST(ConfigParsingTests, AllArgs) { @@ -19,7 +19,7 @@ TEST(ConfigParsingTests, AllArgs) { const_cast("--num_http_threads"), const_cast("1"), const_cast("--log_level"), const_cast("info")}; - onnxruntime::hosting::ServerConfiguration config{}; + onnxruntime::server::ServerConfiguration config{}; Result res = config.ParseInput(11, test_argv); EXPECT_EQ(res, Result::ContinueSuccess); EXPECT_EQ(config.model_path, "testdata/mul_1.pb"); @@ -35,7 +35,7 @@ TEST(ConfigParsingTests, Defaults) { const_cast("--model"), const_cast("testdata/mul_1.pb"), const_cast("--num_http_threads"), const_cast("3")}; - onnxruntime::hosting::ServerConfiguration config{}; + onnxruntime::server::ServerConfiguration config{}; Result res = config.ParseInput(5, test_argv); EXPECT_EQ(res, Result::ContinueSuccess); EXPECT_EQ(config.model_path, "testdata/mul_1.pb"); @@ -50,7 +50,7 @@ TEST(ConfigParsingTests, Help) { const_cast("/path/to/binary"), const_cast("--help")}; - onnxruntime::hosting::ServerConfiguration config{}; + onnxruntime::server::ServerConfiguration config{}; auto res = config.ParseInput(2, test_argv); EXPECT_EQ(res, Result::ExitSuccess); } @@ -60,7 +60,7 @@ TEST(ConfigParsingTests, NoModelArg) { const_cast("/path/to/binary"), const_cast("--num_http_threads"), const_cast("3")}; - onnxruntime::hosting::ServerConfiguration config{}; + onnxruntime::server::ServerConfiguration config{}; Result res = config.ParseInput(3, test_argv); EXPECT_EQ(res, Result::ExitFailure); } @@ -73,7 +73,7 @@ TEST(ConfigParsingTests, ModelNotFound) { const_cast("--http_port"), const_cast("80"), const_cast("--num_http_threads"), const_cast("1")}; - onnxruntime::hosting::ServerConfiguration config{}; + onnxruntime::server::ServerConfiguration config{}; Result res = config.ParseInput(9, test_argv); EXPECT_EQ(res, Result::ExitFailure); } @@ -87,11 +87,11 @@ TEST(ConfigParsingTests, WrongLoggingLevel) { const_cast("--http_port"), const_cast("80"), const_cast("--num_http_threads"), const_cast("1")}; - onnxruntime::hosting::ServerConfiguration config{}; + onnxruntime::server::ServerConfiguration config{}; Result res = config.ParseInput(11, test_argv); EXPECT_EQ(res, Result::ExitFailure); } } // namespace test -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/test/hosting/unit_tests/test_main.cc b/onnxruntime/test/server/unit_tests/test_main.cc similarity index 100% rename from onnxruntime/test/hosting/unit_tests/test_main.cc rename to onnxruntime/test/server/unit_tests/test_main.cc diff --git a/onnxruntime/test/hosting/unit_tests/util_tests.cc b/onnxruntime/test/server/unit_tests/util_tests.cc similarity index 97% rename from onnxruntime/test/hosting/unit_tests/util_tests.cc rename to onnxruntime/test/server/unit_tests/util_tests.cc index 9ed7aaa8f9334..c16f87c4a712b 100644 --- a/onnxruntime/test/hosting/unit_tests/util_tests.cc +++ b/onnxruntime/test/server/unit_tests/util_tests.cc @@ -3,11 +3,11 @@ #include #include "gtest/gtest.h" -#include "hosting/http/core/context.h" -#include "hosting/http/util.h" +#include "server/http/core/context.h" +#include "server/http/util.h" namespace onnxruntime { -namespace hosting { +namespace server { namespace test { namespace protobufutil = google::protobuf::util; @@ -117,5 +117,5 @@ TEST(ContentTypeTests, ContentTypeMissing) { } } // namespace test -} // namespace hosting +} // namespace server } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/test/testdata/hosting/mnist.onnx b/onnxruntime/test/testdata/hosting/mnist.onnx deleted file mode 100644 index fc1a3f733c6e6..0000000000000 Binary files a/onnxruntime/test/testdata/hosting/mnist.onnx and /dev/null differ diff --git a/onnxruntime/test/testdata/hosting/mnist_test_data_set_0_input.json b/onnxruntime/test/testdata/server/mnist_test_data_set_0_input.json similarity index 100% rename from onnxruntime/test/testdata/hosting/mnist_test_data_set_0_input.json rename to onnxruntime/test/testdata/server/mnist_test_data_set_0_input.json diff --git a/onnxruntime/test/testdata/hosting/mnist_test_data_set_0_input.pb b/onnxruntime/test/testdata/server/mnist_test_data_set_0_input.pb similarity index 100% rename from onnxruntime/test/testdata/hosting/mnist_test_data_set_0_input.pb rename to onnxruntime/test/testdata/server/mnist_test_data_set_0_input.pb diff --git a/onnxruntime/test/testdata/hosting/mnist_test_data_set_0_output.json b/onnxruntime/test/testdata/server/mnist_test_data_set_0_output.json similarity index 100% rename from onnxruntime/test/testdata/hosting/mnist_test_data_set_0_output.json rename to onnxruntime/test/testdata/server/mnist_test_data_set_0_output.json diff --git a/onnxruntime/test/testdata/hosting/mnist_test_data_set_0_output.pb b/onnxruntime/test/testdata/server/mnist_test_data_set_0_output.pb similarity index 100% rename from onnxruntime/test/testdata/hosting/mnist_test_data_set_0_output.pb rename to onnxruntime/test/testdata/server/mnist_test_data_set_0_output.pb diff --git a/onnxruntime/test/testdata/hosting/request_0.pb b/onnxruntime/test/testdata/server/request_0.pb similarity index 100% rename from onnxruntime/test/testdata/hosting/request_0.pb rename to onnxruntime/test/testdata/server/request_0.pb diff --git a/onnxruntime/test/testdata/hosting/response_0.pb b/onnxruntime/test/testdata/server/response_0.pb similarity index 100% rename from onnxruntime/test/testdata/hosting/response_0.pb rename to onnxruntime/test/testdata/server/response_0.pb diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 0d0645ff77853..e3f2edd186a33 100755 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -95,9 +95,9 @@ def parse_arguments(): # Build a shared lib parser.add_argument("--build_shared_lib", action='store_true', help="Build a shared library for the ONNXRuntime.") - # Build ONNX hosting - parser.add_argument("--build_hosting", action='store_true', help="Build hosting application for the ONNXRuntime.") - parser.add_argument("--enable_hosting_tests", action='store_true', help="Run hosting application tests.") + # Build ONNX Runtime server + parser.add_argument("--build_server", action='store_true', help="Build server application for the ONNXRuntime.") + parser.add_argument("--enable_server_tests", action='store_true', help="Run server application tests.") # Build options parser.add_argument("--cmake_extra_defines", nargs="+", @@ -328,10 +328,10 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home "-Donnxruntime_TENSORRT_HOME=" + (tensorrt_home if args.use_tensorrt else ""), # By default - we currently support only cross compiling for ARM/ARM64 (no native compilation supported through this script) "-Donnxruntime_CROSS_COMPILING=" + ("ON" if args.arm64 or args.arm else "OFF"), - "-Donnxruntime_BUILD_HOSTING=" + ("ON" if args.build_hosting else "OFF"), + "-Donnxruntime_BUILD_SERVER=" + ("ON" if args.build_server else "OFF"), "-Donnxruntime_BUILD_x86=" + ("ON" if args.x86 else "OFF"), # nGraph and TensorRT providers currently only supports full_protobuf option. - "-Donnxruntime_USE_FULL_PROTOBUF=" + ("ON" if args.use_full_protobuf or args.use_ngraph or args.use_tensorrt or args.build_hosting else "OFF"), + "-Donnxruntime_USE_FULL_PROTOBUF=" + ("ON" if args.use_full_protobuf or args.use_ngraph or args.use_tensorrt or args.build_server else "OFF"), "-Donnxruntime_DISABLE_CONTRIB_OPS=" + ("ON" if args.disable_contrib_ops else "OFF"), "-Donnxruntime_MSVC_STATIC_RUNTIME=" + ("ON" if args.enable_msvc_static_runtime else "OFF"), ] @@ -571,14 +571,14 @@ def run_onnx_tests(build_dir, configs, onnx_test_data_dir, provider, enable_para run_subprocess([exe,'-x'] + cmd, cwd=cwd) -def run_hosting_tests(build_dir, configs): +def run_server_tests(build_dir, configs): run_subprocess([sys.executable, '-m', 'pip', 'install', '--trusted-host', 'files.pythonhosted.org', 'requests']) for config in configs: config_build_dir = get_config_build_dir(build_dir, config) - hosting_app_path = os.path.join(config_build_dir, 'onnxruntime_hosting') - hosting_test_folder = os.path.join(config_build_dir, 'hosting_test') - hosting_test_data_folder = os.path.join(os.path.join(config_build_dir, 'testdata'), 'hosting') - run_subprocess([sys.executable, 'test_main.py', hosting_app_path, hosting_test_data_folder, hosting_test_data_folder], cwd=hosting_test_folder, dll_path=None) + server_app_path = os.path.join(config_build_dir, 'onnxruntime_server') + server_test_folder = os.path.join(config_build_dir, 'server_test') + server_test_data_folder = os.path.join(os.path.join(config_build_dir, 'testdata'), 'server') + run_subprocess([sys.executable, 'test_main.py', server_app_path, server_test_data_folder, server_test_data_folder], cwd=server_test_folder, dll_path=None) def build_python_wheel(source_dir, build_dir, configs, use_cuda, use_ngraph, use_tensorrt, nightly_build = False): for config in configs: @@ -781,8 +781,8 @@ def main(): if args.use_mkldnn: run_onnx_tests(build_dir, configs, onnx_test_data_dir, 'mkldnn', True, 1) - if args.build_hosting and args.enable_hosting_tests: - run_hosting_tests(build_dir, configs) + if args.build_server and args.enable_server_tests: + run_server_tests(build_dir, configs) if args.build: if args.build_wheel: diff --git a/tools/ci_build/github/azure-pipelines/vienna-linux-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/vienna-linux-ci-pipeline.yml index 572cce584ece5..16d0fe959958a 100644 --- a/tools/ci_build/github/azure-pipelines/vienna-linux-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/vienna-linux-ci-pipeline.yml @@ -3,7 +3,7 @@ jobs: pool: Hosted Ubuntu 1604 steps: - template: templates/set-test-data-variables-step.yml - - script: 'tools/ci_build/github/linux/hosting_run_dockerbuild.sh -o ubuntu16.04 -d cpu -r $(Build.BinariesDirectory) -k $(acr.key) -x "--config Debug --build_hosting --use_openmp --use_full_protobuf --enable_hosting_tests"' + - script: 'tools/ci_build/github/linux/server_run_dockerbuild.sh -o ubuntu16.04 -d cpu -r $(Build.BinariesDirectory) -k $(acr.key) -x "--config Debug --build_server --use_openmp --use_full_protobuf --enable_server_tests"' displayName: 'Debug Build' - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 displayName: 'Component Detection' @@ -12,7 +12,7 @@ jobs: pool: Hosted Ubuntu 1604 steps: - template: templates/set-test-data-variables-step.yml - - script: 'tools/ci_build/github/linux/hosting_run_dockerbuild.sh -o ubuntu16.04 -d cpu -r $(Build.BinariesDirectory) -k $(acr.key) -x "--config Release --build_hosting --use_openmp --use_full_protobuf --enable_hosting_tests"' + - script: 'tools/ci_build/github/linux/server_run_dockerbuild.sh -o ubuntu16.04 -d cpu -r $(Build.BinariesDirectory) -k $(acr.key) -x "--config Release --build_server --use_openmp --use_full_protobuf --enable_server_tests"' displayName: 'Release Build' - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 displayName: 'Component Detection' diff --git a/tools/ci_build/github/linux/hosting_run_build.sh b/tools/ci_build/github/linux/server_run_build.sh similarity index 100% rename from tools/ci_build/github/linux/hosting_run_build.sh rename to tools/ci_build/github/linux/server_run_build.sh diff --git a/tools/ci_build/github/linux/hosting_run_dockerbuild.sh b/tools/ci_build/github/linux/server_run_dockerbuild.sh similarity index 93% rename from tools/ci_build/github/linux/hosting_run_dockerbuild.sh rename to tools/ci_build/github/linux/server_run_dockerbuild.sh index 7e0ea192d946b..87869b1df811d 100755 --- a/tools/ci_build/github/linux/hosting_run_dockerbuild.sh +++ b/tools/ci_build/github/linux/server_run_dockerbuild.sh @@ -55,7 +55,7 @@ fi --volume "$BUILD_DIR:/home/onnxruntimedev" \ --volume "$HOME/.cache/onnxruntime:/home/onnxruntimedev/.cache/onnxruntime" \ "onnxruntime-$IMAGE" \ - /bin/bash /onnxruntime_src/tools/ci_build/github/linux/hosting_run_build.sh \ + /bin/bash /onnxruntime_src/tools/ci_build/github/linux/server_run_build.sh \ -d $BUILD_DEVICE -x "$BUILD_EXTR_PAR" & else docker rm -f "onnxruntime-$BUILD_DEVICE" || true @@ -66,7 +66,7 @@ else --volume "$BUILD_DIR:/home/onnxruntimedev" \ --volume "$HOME/.cache/onnxruntime:/home/onnxruntimedev/.cache/onnxruntime" \ "onnxruntime-$IMAGE" \ - /bin/bash /onnxruntime_src/tools/ci_build/github/linux/hosting_run_build.sh \ + /bin/bash /onnxruntime_src/tools/ci_build/github/linux/server_run_build.sh \ -d $BUILD_DEVICE -x "$BUILD_EXTR_PAR" & fi wait -n