Skip to content

Commit

Permalink
Merge branch 'main' of github.com:microsoft/onnxruntime into abjindal…
Browse files Browse the repository at this point in the history
…/update_deepspeed_version
  • Loading branch information
ajindal1 committed Feb 1, 2023
2 parents 28fb80a + d06ad94 commit 0a9550a
Show file tree
Hide file tree
Showing 53 changed files with 915 additions and 154 deletions.
12 changes: 11 additions & 1 deletion cgmanifests/generated/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "5a5f8a5935762397aa68429b5493084ff970f774",
"commitHash": "9b7bca2a723ff94edcd007d93b5d0cf1838591dc",
"repositoryUrl": "https://github.com/onnx/onnx.git"
},
"comments": "git submodule at cmake/external/onnx"
Expand Down Expand Up @@ -318,6 +318,16 @@
"comments": "onnx_tensorrt"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "a20c65f2cd549445fda907f7b83894c8eb7427d6",
"repositoryUrl": "https://github.com/protocolbuffers/protobuf.git"
},
"comments": "protobuf"
}
},
{
"component": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ endif()

if (onnxruntime_USE_DNNL)
include(dnnl)
add_compile_definitions(DNNL_OPENMP)
endif()

# TVM EP
Expand Down
4 changes: 2 additions & 2 deletions cmake/deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ microsoft_gsl;https://github.com/microsoft/GSL/archive/refs/tags/v4.0.0.zip;cf36
microsoft_wil;https://github.com/microsoft/wil/archive/5f4caba4e7a9017816e47becdd918fcc872039ba.zip;fd119887d0d17c37adf1fc227b054befa28158ad
mimalloc;https://github.com/microsoft/mimalloc/archive/refs/tags/v2.0.3.zip;e4f37b93b2da78a5816c2495603a4188d316214b
mp11;https://github.com/boostorg/mp11/archive/refs/tags/boost-1.79.0.zip;c8f04e378535ededbe5af52c8f969d2dedbe73d5
onnx;https://github.com/onnx/onnx/archive/1ba785612a79fe749aa1e478336e534743372639.zip;6c22c32fabafac81107186ea6bedb31741a3142d
onnx;https://github.com/onnx/onnx/archive/refs/tags/v1.13.0.zip;8dda5079cdb5a134b08b0c73f4592a6404fc2dc6
#use the commit where it's several commits after 8.5-GA branch (https://github.com/onnx/onnx-tensorrt/commit/369d6676423c2a6dbf4a5665c4b5010240d99d3c)
onnx_tensorrt;https://github.com/onnx/onnx-tensorrt/archive/369d6676423c2a6dbf4a5665c4b5010240d99d3c.zip;62119892edfb78689061790140c439b111491275
protobuf;https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.18.3.zip;b95bf7e9de9c2249b6c1f2ca556ace49999e90bd
protobuf;https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.20.2.zip;9f71dad95fb83438e88822a9969fc93773fd8c48
psimd;https://github.com/Maratyszcza/psimd/archive/072586a71b55b7f8c584153d223e95687148a900.zip;1f5454b01f06f9656b77e4a5e2e31d7422487013
pthreadpool;https://github.com/Maratyszcza/pthreadpool/archive/1787867f6183f056420e532eec640cba25efafea.zip;e43e80781560c5ab404a4da20f34d846f5f5d101
pybind11;https://github.com/pybind/pybind11/archive/refs/tags/v2.10.1.zip;769b6aa67a77f17a770960f604b727645b6f6a13
Expand Down
2 changes: 1 addition & 1 deletion cmake/external/onnxruntime_external_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ FetchContent_Declare(
URL_HASH SHA1=${DEP_SHA1_protobuf}
SOURCE_SUBDIR cmake
PATCH_COMMAND ${ONNXRUNTIME_PROTOBUF_PATCH_COMMAND}
FIND_PACKAGE_ARGS 3.18.0 NAMES Protobuf
FIND_PACKAGE_ARGS 3.20.2 NAMES Protobuf
)
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests" FORCE)
if (CMAKE_SYSTEM_NAME STREQUAL "Android")
Expand Down
2 changes: 1 addition & 1 deletion cmake/external/protobuf
Submodule protobuf updated 894 files
5 changes: 5 additions & 0 deletions cmake/onnxruntime_providers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ if (onnxruntime_USE_DNNL)
target_include_directories(onnxruntime_providers_dnnl PRIVATE ${ORTTRAINING_ROOT})
endif()

# Needed for threadpool handling
if(onnxruntime_BUILD_JAVA)
add_compile_definitions(DNNL_JAVA)
endif()

if(APPLE)
set_property(TARGET onnxruntime_providers_dnnl APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker -exported_symbols_list ${ONNXRUNTIME_ROOT}/core/providers/dnnl/exported_symbols.lst")
set_target_properties(onnxruntime_providers_dnnl PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion cmake/onnxruntime_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ if (MSVC)
# The warning means the type of two integral values around a binary operator is narrow than their result.
# If we promote the two input values first, it could be more tolerant to integer overflow.
# However, this is test code. We are less concerned.
target_compile_options(onnxruntime_test_all PRIVATE "/wd26451")
target_compile_options(onnxruntime_test_all PRIVATE "/wd26451" "/wd4244")
else()
target_compile_options(onnxruntime_test_all PRIVATE "-Wno-parentheses")
endif()
Expand Down
38 changes: 36 additions & 2 deletions cmake/patches/onnx/onnx.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e595855..789ec80a 100644
index 4dd56b6e..018da488 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -545,20 +545,9 @@ endif()
@@ -397,6 +397,7 @@ if (MSVC)
endif()
else()
# On non-Windows, hide all symbols we don't need
+ set(EXTRA_FLAGS "-Wno-unused-parameter")
set(ONNX_API_DEFINE "-DONNX_API=__attribute__\(\(__visibility__\(\"default\"\)\)\)")
set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(onnx_proto PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
@@ -548,20 +549,9 @@ endif()
if(MSVC)
target_compile_options(onnx_proto
PRIVATE /MP
Expand All @@ -23,3 +31,29 @@ index 8e595855..789ec80a 100644
${EXTRA_FLAGS})
if(ONNX_USE_PROTOBUF_SHARED_LIBS)
target_compile_options(onnx_proto
diff --git a/onnx/onnx_pb.h b/onnx/onnx_pb.h
index 0aab3e26..0f859267 100644
--- a/onnx/onnx_pb.h
+++ b/onnx/onnx_pb.h
@@ -47,10 +47,21 @@
#define ONNX_API ONNX_IMPORT
#endif

+// onnx/onnx-operators-ml.pb.h:1178:25: required from here
+// protobuf/src/google/protobuf/repeated_ptr_field.h:752:66: error: unused parameter ‘prototype’ [-Werror=unused-parameter]
+#if defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
#ifdef ONNX_ML
#include "onnx/onnx-ml.pb.h"
#else
#include "onnx/onnx.pb.h"
#endif

+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
+
#endif // ! ONNX_ONNX_PB_H
18 changes: 12 additions & 6 deletions cmake/patches/protobuf/protobuf_cmake.patch
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 61a5c3ded..68d7c5598 100644
index ac92442a1..e930cbd2e 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -199,12 +199,8 @@ if (MSVC)
endif()
@@ -240,9 +240,7 @@ if (MSVC)
# MSVC warning suppressions
add_definitions(
- /wd4018 # 'expression' : signed/unsigned mismatch
/wd4065 # switch statement contains 'default' but no 'case' labels
- /wd4146 # unary minus operator applied to unsigned type, result still unsigned
- /wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
/wd4251 # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
- /wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
/wd4305 # 'identifier' : truncation from 'type1' to 'type2'
/wd4307 # 'operator' : integral constant overflow
/wd4309 # 'conversion' : truncation of constant value
@@ -212,7 +208,6 @@ if (MSVC)
@@ -250,7 +248,6 @@ if (MSVC)
/wd4355 # 'this' : used in base member initializer list
/wd4506 # no definition for inline function 'function'
/wd4800 # 'type' : forcing value to bool 'true' or 'false' (performance warning)
- /wd4996 # The compiler encountered a deprecated declaration.
)
# Allow big object
add_definitions(/bigobj)
@@ -272,6 +269,8 @@ if (MSVC)
endif()

configure_file(version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
+else (MSVC)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
endif (MSVC)


17 changes: 0 additions & 17 deletions include/onnxruntime/core/providers/dnnl/dnnl_provider_factory.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright(C) 2022 Intel Corporation
// Licensed under the MIT License
#pragma once

struct OrtDnnlProviderOptions {
int use_arena; // If arena is used, use_arena 0 = not used, nonzero = used
void* threadpool_args; // Used to enable configure the oneDNN threadpool
};
78 changes: 78 additions & 0 deletions include/onnxruntime/core/session/onnxruntime_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ ORT_RUNTIME_CLASS(PrepackedWeightsContainer);
ORT_RUNTIME_CLASS(TensorRTProviderOptionsV2);
ORT_RUNTIME_CLASS(CUDAProviderOptionsV2);
ORT_RUNTIME_CLASS(CANNProviderOptions);
ORT_RUNTIME_CLASS(DnnlProviderOptions);
ORT_RUNTIME_CLASS(Op);
ORT_RUNTIME_CLASS(OpAttr);

Expand Down Expand Up @@ -3879,6 +3880,73 @@ struct OrtApi {

/// @}

/** \brief Append dnnl provider to session options
*
* If oneDNN is not available, this function will return failure.
*
* \param[in] options
* \param[in] cann_options
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*
* \since Version 1.14.
*/
ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_Dnnl,
_In_ OrtSessionOptions* options, _In_ const OrtDnnlProviderOptions* dnnl_options);

/** \brief Create an OrtDnnlProviderOptions
*
* \param[out] out Newly created ::OrtDnnlProviderOptions. Must be released with OrtApi::ReleaseDnnlProviderOptions
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*
* \since Version 1.14.
*/
ORT_API2_STATUS(CreateDnnlProviderOptions, _Outptr_ OrtDnnlProviderOptions** out);

/** \brief Set options in a oneDNN Execution Provider.
*
* Key should be in null terminated string format of the member of ::OrtDnnlProviderOptions
* and value should be its related range.
*
* For example, key="use_arena" and value="1"
*
* \param[in] dnnl_options
* \param[in] provider_options_keys Array of UTF-8 null-terminated string for provider options keys
* \param[in] provider_options_values Array of UTF-8 null-terminated string for provider options values
* \param[in] num_keys Number of elements in the `provider_option_keys` and `provider_options_values` arrays
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*
* \since Version 1.14.
*/
ORT_API2_STATUS(UpdateDnnlProviderOptions, _Inout_ OrtDnnlProviderOptions* dnnl_options,
_In_reads_(num_keys) const char* const* provider_options_keys,
_In_reads_(num_keys) const char* const* provider_options_values,
_In_ size_t num_keys);

/**
* Get serialized oneDNN provider options string.
*
* For example, "use_arena=1;......"
*
* \param dnnl_options - OrtDnnlProviderOptions instance
* \param allocator - a ptr to an instance of OrtAllocator obtained with CreateAllocator() or GetAllocatorWithDefaultOptions()
* the specified allocator will be used to allocate continuous buffers for output strings and lengths.
* \param ptr - is a UTF-8 null terminated string allocated using 'allocator'. The caller is responsible for using the same allocator to free it.
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*
* \since Version 1.14.
*/
ORT_API2_STATUS(GetDnnlProviderOptionsAsString, _In_ const OrtDnnlProviderOptions* dnnl_options, _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);

/** \brief Release an ::OrtDnnlProviderOptions
*
* \since Version 1.14.
*/
void(ORT_API_CALL* ReleaseDnnlProviderOptions)(_Frees_ptr_opt_ OrtDnnlProviderOptions* input);

#ifdef __cplusplus
OrtApi(const OrtApi&) = delete; // Prevent users from accidentally copying the API structure, it should always be passed as a pointer
#endif
Expand Down Expand Up @@ -3980,6 +4048,16 @@ ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_CUDA, _In_ OrtSessionOpt
*/
ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_MIGraphX, _In_ OrtSessionOptions* options, int device_id);

/*
* This is the old way to add the oneDNN provider to the session, please use
* SessionOptionsAppendExecutionProvider_oneDNN above to access the latest functionality
* This function always exists, but will only succeed if Onnxruntime was built with
* oneDNN support and the oneDNN provider shared library exists
*
* \param use_arena zero: false. non-zero: true.
*/
ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_Dnnl, _In_ OrtSessionOptions* options, int use_arena);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/onnxruntime/core/session/onnxruntime_cxx_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ struct SessionOptionsImpl : ConstSessionOptionsImpl<T> {
SessionOptionsImpl& AppendExecutionProvider_MIGraphX(const OrtMIGraphXProviderOptions& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_MIGraphX
///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_CANN
SessionOptionsImpl& AppendExecutionProvider_CANN(const OrtCANNProviderOptions& provider_options);
///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_Dnnl
SessionOptionsImpl& AppendExecutionProvider_Dnnl(const OrtDnnlProviderOptions& provider_options);
/// Wraps OrtApi::SessionOptionsAppendExecutionProvider. Currently supports SNPE and XNNPACK.
SessionOptionsImpl& AppendExecutionProvider(const std::string& provider_name,
const std::unordered_map<std::string, std::string>& provider_options = {});
Expand Down
6 changes: 6 additions & 0 deletions include/onnxruntime/core/session/onnxruntime_cxx_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,12 @@ inline SessionOptionsImpl<T>& SessionOptionsImpl<T>::AppendExecutionProvider_CAN
return *this;
}

template <typename T>
inline SessionOptionsImpl<T>& SessionOptionsImpl<T>::AppendExecutionProvider_Dnnl(const OrtDnnlProviderOptions& provider_options) {
ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider_Dnnl(this->p_, &provider_options));
return *this;
}

template <typename T>
inline SessionOptionsImpl<T>& SessionOptionsImpl<T>::AppendExecutionProvider(
const std::string& provider_name,
Expand Down
15 changes: 11 additions & 4 deletions java/src/main/native/ai_onnxruntime_OrtSession_SessionOptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// Providers
#define ORT_JAVA_MAX_ARGUMENT_ARRAY_LENGTH 128
#include "onnxruntime/core/providers/cpu/cpu_provider_factory.h"
#include "onnxruntime/core/providers/dnnl/dnnl_provider_factory.h"
#include "onnxruntime/core/providers/nnapi/nnapi_provider_factory.h"
#include "onnxruntime/core/providers/tvm/tvm_provider_factory.h"
#include "onnxruntime/core/providers/openvino/openvino_provider_factory.h"
Expand All @@ -29,6 +28,11 @@
#include "onnxruntime/core/providers/dml/dml_provider_factory.h"
#endif

#ifdef USE_DNNL
#include "core/providers/dnnl/dnnl_provider_options.h"
#endif


/*
* Class: ai_onnxruntime_OrtSession_SessionOptions
* Method: setExecutionMode
Expand Down Expand Up @@ -431,9 +435,12 @@ JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_addDnn
(JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint useArena) {
(void)jobj;
#ifdef USE_DNNL
checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,OrtSessionOptionsAppendExecutionProvider_Dnnl((OrtSessionOptions*) handle,useArena));
#else
(void)apiHandle;(void)handle;(void)useArena; // Parameters used when DNNL is defined.
OrtDnnlProviderOptions dnnl_options;
dnnl_options.use_arena = useArena; // Follow the user command
const OrtApi* api = (OrtApi*)apiHandle;
checkOrtStatus(jniEnv, api, api->SessionOptionsAppendExecutionProvider_Dnnl((OrtSessionOptions*)handle, &dnnl_options));
#else
(void)apiHandle; (void)handle; (void)useArena; // Parameters used when DNNL is defined.
throwOrtException(jniEnv,convertErrorCode(ORT_INVALID_ARGUMENT),"This binary was not compiled with DNNL support.");
#endif
}
Expand Down
Loading

0 comments on commit 0a9550a

Please sign in to comment.