diff --git a/.gitmodules b/.gitmodules index 7b8ea9ae26..567e643b6e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -59,6 +59,9 @@ [submodule "cmake/external/optional-lite"] path = cmake/external/optional-lite url = https://github.com/martinmoene/optional-lite.git +[submodule "cmake/external/mp11"] + path = cmake/external/mp11 + url = https://github.com/boostorg/mp11.git [submodule "cmake/external/coremltools"] path = cmake/external/coremltools url = https://github.com/apple/coremltools.git diff --git a/cgmanifests/submodules/cgmanifest.json b/cgmanifests/submodules/cgmanifest.json index 1378318a1b..4d61c1f44a 100644 --- a/cgmanifests/submodules/cgmanifest.json +++ b/cgmanifests/submodules/cgmanifest.json @@ -218,6 +218,16 @@ "comments": "git submodule at cmake/external/mimalloc" } }, + { + "component": { + "type": "git", + "git": { + "commitHash": "21cace4e574180ba64d9307a5e4ea9e5e94d3e8d", + "repositoryUrl": "https://github.com/boostorg/mp11.git" + }, + "comments": "git submodule at cmake/external/mp11" + } + }, { "component": { "type": "git", diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 969b9d271b..35aef18d35 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -662,10 +662,6 @@ set(ONNXRUNTIME_INCLUDE_DIR ${REPO_ROOT}/include/onnxruntime) add_subdirectory(external/date EXCLUDE_FROM_ALL) -if(onnxruntime_PREFER_SYSTEM_LIB) - find_package(re2) -endif() - set(SAFEINT_INCLUDE_DIR ${REPO_ROOT}/cmake/external/SafeInt) add_library(safeint_interface INTERFACE) target_include_directories(safeint_interface INTERFACE ${SAFEINT_INCLUDE_DIR}) @@ -675,6 +671,11 @@ if(onnxruntime_DISABLE_EXCEPTIONS) add_compile_definitions(optional_CONFIG_NO_EXCEPTIONS=1) endif() +add_subdirectory(external/mp11 EXCLUDE_FROM_ALL) + +if(onnxruntime_PREFER_SYSTEM_LIB) + find_package(re2) +endif() if(NOT TARGET re2::re2) add_subdirectory(external/re2 EXCLUDE_FROM_ALL) set_target_properties(re2 PROPERTIES FOLDER "External/re2") diff --git a/cmake/external/mp11 b/cmake/external/mp11 new file mode 160000 index 0000000000..21cace4e57 --- /dev/null +++ b/cmake/external/mp11 @@ -0,0 +1 @@ +Subproject commit 21cace4e574180ba64d9307a5e4ea9e5e94d3e8d diff --git a/cmake/onnxruntime_common.cmake b/cmake/onnxruntime_common.cmake index d51c72a2d7..c9dd4326cc 100644 --- a/cmake/onnxruntime_common.cmake +++ b/cmake/onnxruntime_common.cmake @@ -105,6 +105,8 @@ target_include_directories(onnxruntime_common $ ${OPTIONAL_LITE_INCLUDE_DIR}) +target_link_libraries(onnxruntime_common Boost::mp11) + if(NOT WIN32) target_include_directories(onnxruntime_common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/external/nsync/public") endif() diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake index c2f13294c9..f89ce5b4ec 100644 --- a/cmake/onnxruntime_providers.cmake +++ b/cmake/onnxruntime_providers.cmake @@ -53,6 +53,7 @@ file(GLOB onnxruntime_cpu_featurizers_cc_srcs CONFIGURE_DEPENDS file(GLOB onnxruntime_providers_common_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/providers/*.h" "${ONNXRUNTIME_ROOT}/core/providers/*.cc" + "${ONNXRUNTIME_ROOT}/core/providers/op_kernel_type_control_overrides.inc" ) if(onnxruntime_USE_NUPHAR) diff --git a/cmake/winml.cmake b/cmake/winml.cmake index 99edff77dc..20f25d6234 100644 --- a/cmake/winml.cmake +++ b/cmake/winml.cmake @@ -397,6 +397,7 @@ target_include_directories(winml_lib_image PRIVATE ${REPO_ROOT}/cmake/external/p target_include_directories(winml_lib_image PRIVATE ${ONNXRUNTIME_INCLUDE_DIR}/core/platform/windows) target_include_directories(winml_lib_image PRIVATE ${REPO_ROOT}/cmake/external/flatbuffers/include) target_include_directories(winml_lib_image PRIVATE ${REPO_ROOT}/cmake/external/optional-lite/include) +target_include_directories(winml_lib_image PRIVATE ${REPO_ROOT}/cmake/external/mp11/include) # Properties set_target_properties(winml_lib_image @@ -512,6 +513,7 @@ target_include_directories(winml_lib_api PRIVATE ${REPO_ROOT}/cmake/external/gsl target_include_directories(winml_lib_api PRIVATE ${REPO_ROOT}/cmake/external/SafeInt) target_include_directories(winml_lib_api PRIVATE ${REPO_ROOT}/cmake/external/flatbuffers/include) target_include_directories(winml_lib_api PRIVATE ${REPO_ROOT}/cmake/external/optional-lite/include) +target_include_directories(winml_lib_api PRIVATE ${REPO_ROOT}/cmake/external/mp11/include) # Properties set_target_properties(winml_lib_api @@ -594,6 +596,7 @@ target_include_directories(winml_lib_api_experimental PRIVATE ${REPO_ROOT}/cmake target_include_directories(winml_lib_api_experimental PRIVATE ${REPO_ROOT}/cmake/external/SafeInt) target_include_directories(winml_lib_api_experimental PRIVATE ${REPO_ROOT}/cmake/external/flatbuffers/include) target_include_directories(winml_lib_api_experimental PRIVATE ${REPO_ROOT}/cmake/external/optional-lite/include) +target_include_directories(winml_lib_api_experimental PRIVATE ${REPO_ROOT}/cmake/external/mp11/include) # Properties set_target_properties(winml_lib_api_experimental @@ -748,6 +751,7 @@ target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/cmake/external/eigen) target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/cmake/external/SafeInt) target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/cmake/external/flatbuffers/include) target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/cmake/external/optional-lite/include) +target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/cmake/external/mp11/include) # Properties set_target_properties(winml_dll diff --git a/cmake/winml_unittests.cmake b/cmake/winml_unittests.cmake index 1479909683..012cb0af07 100644 --- a/cmake/winml_unittests.cmake +++ b/cmake/winml_unittests.cmake @@ -163,7 +163,7 @@ function (get_winml_test_model_src "${winml_test_src_path}/model/*.cpp") set(${output_winml_test_model_src} ${winml_test_model_src} PARENT_SCOPE) set(${winml_test_model_libs} onnx_test_data_proto onnx_test_runner_common onnxruntime_common onnxruntime_mlas - onnxruntime_graph onnxruntime_test_utils onnxruntime_framework onnxruntime_flatbuffers PARENT_SCOPE) + onnxruntime_graph onnxruntime_test_utils onnxruntime_framework onnxruntime_util onnxruntime_flatbuffers PARENT_SCOPE) endfunction() file(GLOB winml_test_common_src CONFIGURE_DEPENDS diff --git a/include/onnxruntime/core/framework/data_types.h b/include/onnxruntime/core/framework/data_types.h index 6d4633ab5f..4e7f3c6e60 100644 --- a/include/onnxruntime/core/framework/data_types.h +++ b/include/onnxruntime/core/framework/data_types.h @@ -52,11 +52,12 @@ class NonTensorTypeBase; class PrimitiveDataTypeBase; // MLFloat16 -union MLFloat16 { +struct MLFloat16 { uint16_t val; - explicit MLFloat16(uint16_t x) : val(x) {} MLFloat16() : val(0) {} + explicit MLFloat16(uint16_t x) : val(x) {} + explicit MLFloat16(float f); // Taken from https://stackoverflow.com/a/60047308/12627730 float AsFloat(uint32_t x) const { diff --git a/include/onnxruntime/core/framework/data_types_internal.h b/include/onnxruntime/core/framework/data_types_internal.h index 1f154fc53e..c195deaee0 100644 --- a/include/onnxruntime/core/framework/data_types_internal.h +++ b/include/onnxruntime/core/framework/data_types_internal.h @@ -3,12 +3,16 @@ #pragma once -#include -#include +#include +#include +#include #include #include +#include "boost/mp11.hpp" + #include "core/common/common.h" +#include "core/common/type_list.h" #include "core/framework/data_types.h" #include "core/graph/onnx_protobuf.h" @@ -341,25 +345,54 @@ class MLTypeCallDispatcherRet { } }; -// Version of the MLTypeDispatcher that has an input type which is passed through ('carried') -// as the first type parameter in the call to Fn when dispatching. -template class Fn, typename... Types> -class MLTypeCallDispatcherWithCarriedType { +// Version of MLTypeCallDispatcher that takes supported types as class-level template parameters. +// This enables easier use with type list representations of the supported types. +// The invocation-related template parameters like Fn move to the individual Invoke() methods. +// TODO consolidate this with the other MLTypeCallDispatcher classes +// can add additional methods to cover their usages, but need to update call sites +template +class MLTypeCallDispatcher2 { + static_assert(boost::mp11::mp_is_set>::value, + "MLTypeCallDispatcher requires a set of unique types."); + int32_t dt_type_; public: - explicit MLTypeCallDispatcherWithCarriedType(int32_t dt_type) noexcept : dt_type_(dt_type) {} + explicit MLTypeCallDispatcher2(int32_t dt_type) noexcept : dt_type_(dt_type) {} - template + template