Skip to content

Commit d4106de

Browse files
xzhu1900MaajidKhanfs-eireRyanUnderhill
authored
Cherry pick outstanding changes into release branch (round 2) (microsoft#7921)
* [OpenVINO-EP] Adding OpenVINO-EP samples to Msft Repo (microsoft#7826) * Added ONNX_OV_EP samples ->Added cpp, python and csharp samples using OpenVINO Execution Provider. Signed-off-by: MaajidKhan <[email protected]> * [js/web] update README.md (microsoft#7894) * Add API_IMPL_* blocks around shared provider methods as they are C APIs (microsoft#7908) * Missing logic for cuda nuget package (microsoft#7911) Co-authored-by: Maajid khan <[email protected]> Co-authored-by: Yulong Wang <[email protected]> Co-authored-by: Ryan Hill <[email protected]>
1 parent a54716e commit d4106de

File tree

9 files changed

+1894
-5
lines changed

9 files changed

+1894
-5
lines changed

js/web/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ The [Open Neural Network Exchange](http://onnx.ai/) (ONNX) is an open standard f
1010

1111
### Why ONNX Runtime Web
1212

13-
With ONNX Runtime Web, web developers can score pre-trained ONNX models directly on browsers with various benefits of reducing server-client communication and protecting user privacy, as well as offering install-free and cross-platform in-browser ML experience.
13+
With ONNX Runtime Web, web developers can score models directly on browsers with various benefits including reducing server-client communication and protecting user privacy, as well as offering install-free and cross-platform in-browser ML experience.
1414

15-
ONNX Runtime Web can run on both CPU and GPU. For running on CPU, [WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly) is adopted to execute the model at near-native speed. Furthermore, ONNX Runtime Web utilizes [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) to provide a "multi-threaded" environment to parallelize data processing. Empirical evaluation shows very promising performance gains on CPU by taking full advantage of WebAssembly and Web Workers. For running on GPUs, a popular standard for accessing GPU capabilities - WebGL is adopted. ONNX Runtime Web has further adopted several novel optimization techniques for reducing data transfer between CPU and GPU, as well as some techniques to reduce GPU processing cycles to further push the performance to the maximum.
15+
ONNX Runtime Web can run on both CPU and GPU. On CPU side, [WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly) is adopted to execute the model at near-native speed. ONNX Runtime Web complies the native ONNX Runtime CPU engine into WebAssembly backend by using Emscripten, so it supports most functionalities native ONNX Runtime offers, including full ONNX operator coverage, multi-threading, [ONNX Runtime Quantization](https://www.onnxruntime.ai/docs/how-to/quantization.html) as well as [ONNX Runtime Mobile](http://www.onnxruntime.ai/docs/how-to/deploy-on-mobile.html). For performance acceleration with GPUs, ONNX Runtime Web leverages WebGL, a popular standard for accessing GPU capabilities. We are keeping improving op coverage and optimizing performance in WebGL backend.
1616

1717
See [Compatibility](#Compatibility) and [Operators Supported](#Operators) for a list of platforms and operators ONNX Runtime Web currently supports.
1818

onnxruntime/core/framework/provider_bridge_ort.cc

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "core/framework/compute_capability.h"
88
#include "core/framework/data_types.h"
99
#include "core/framework/data_transfer_manager.h"
10+
#include "core/framework/error_code_helper.h"
1011
#include "core/framework/execution_provider.h"
1112
#include "core/framework/kernel_registry.h"
1213
#include "core/framework/provider_bridge_ort.h"
@@ -1084,47 +1085,55 @@ INcclService& INcclService::GetInstance() {
10841085
} // namespace onnxruntime
10851086

10861087
ORT_API_STATUS_IMPL(OrtSessionOptionsAppendExecutionProvider_Dnnl, _In_ OrtSessionOptions* options, int use_arena) {
1088+
API_IMPL_BEGIN
10871089
auto factory = onnxruntime::CreateExecutionProviderFactory_Dnnl(use_arena);
10881090
if (!factory) {
10891091
return OrtApis::CreateStatus(ORT_FAIL, "OrtSessionOptionsAppendExecutionProvider_Dnnl: Failed to load shared library");
10901092
}
10911093

10921094
options->provider_factories.push_back(factory);
10931095
return nullptr;
1096+
API_IMPL_END
10941097
}
10951098

10961099
ORT_API_STATUS_IMPL(OrtSessionOptionsAppendExecutionProvider_Tensorrt, _In_ OrtSessionOptions* options, int device_id) {
1100+
API_IMPL_BEGIN
10971101
auto factory = onnxruntime::CreateExecutionProviderFactory_Tensorrt(device_id);
10981102
if (!factory) {
10991103
return OrtApis::CreateStatus(ORT_FAIL, "OrtSessionOptionsAppendExecutionProvider_Tensorrt: Failed to load shared library");
11001104
}
11011105

11021106
options->provider_factories.push_back(factory);
11031107
return nullptr;
1108+
API_IMPL_END
11041109
}
11051110

11061111
ORT_API_STATUS_IMPL(OrtApis::SessionOptionsAppendExecutionProvider_TensorRT, _In_ OrtSessionOptions* options, _In_ const OrtTensorRTProviderOptions* tensorrt_options) {
1112+
API_IMPL_BEGIN
11071113
auto factory = onnxruntime::CreateExecutionProviderFactory_Tensorrt(tensorrt_options);
11081114
if (!factory) {
11091115
return OrtApis::CreateStatus(ORT_FAIL, "SessionOptionsAppendExecutionProvider_Tensorrt: Failed to load shared library");
11101116
}
11111117

11121118
options->provider_factories.push_back(factory);
11131119
return nullptr;
1120+
API_IMPL_END
11141121
}
11151122

11161123
ORT_API_STATUS_IMPL(OrtApis::SessionOptionsAppendExecutionProvider_OpenVINO, _In_ OrtSessionOptions* options, _In_ const OrtOpenVINOProviderOptions* provider_options) {
1124+
API_IMPL_BEGIN
11171125
auto factory = onnxruntime::CreateExecutionProviderFactory_OpenVINO(provider_options);
11181126
if (!factory) {
11191127
return OrtApis::CreateStatus(ORT_FAIL, "SessionOptionsAppendExecutionProvider_OpenVINO: Failed to load shared library");
11201128
}
11211129

11221130
options->provider_factories.push_back(factory);
11231131
return nullptr;
1132+
API_IMPL_END
11241133
}
11251134

11261135
ORT_API_STATUS_IMPL(OrtSessionOptionsAppendExecutionProvider_OpenVINO, _In_ OrtSessionOptions* options, _In_ const char* device_type) {
1127-
OrtOpenVINOProviderOptions provider_options;
1136+
OrtOpenVINOProviderOptions provider_options{};
11281137
provider_options.device_type = device_type;
11291138
return OrtApis::SessionOptionsAppendExecutionProvider_OpenVINO(options, &provider_options);
11301139
}
@@ -1137,23 +1146,29 @@ ORT_API_STATUS_IMPL(OrtSessionOptionsAppendExecutionProvider_CUDA, _In_ OrtSessi
11371146
}
11381147

11391148
ORT_API_STATUS_IMPL(OrtApis::SetCurrentGpuDeviceId, _In_ int device_id) {
1149+
API_IMPL_BEGIN
11401150
if (auto* info = onnxruntime::GetProviderInfo_CUDA())
11411151
return info->SetCurrentGpuDeviceId(device_id);
11421152
return CreateStatus(ORT_FAIL, "CUDA execution provider is not enabled.");
1153+
API_IMPL_END
11431154
}
11441155

11451156
ORT_API_STATUS_IMPL(OrtApis::GetCurrentGpuDeviceId, _In_ int* device_id) {
1157+
API_IMPL_BEGIN
11461158
if (auto* info = onnxruntime::GetProviderInfo_CUDA())
11471159
return info->GetCurrentGpuDeviceId(device_id);
11481160
return CreateStatus(ORT_FAIL, "CUDA execution provider is not enabled.");
1161+
API_IMPL_END
11491162
}
11501163

11511164
ORT_API_STATUS_IMPL(OrtApis::SessionOptionsAppendExecutionProvider_CUDA, _In_ OrtSessionOptions* options, _In_ const OrtCUDAProviderOptions* cuda_options) {
1165+
API_IMPL_BEGIN
11521166
auto factory = onnxruntime::CreateExecutionProviderFactory_Cuda(cuda_options);
11531167
if (!factory) {
11541168
return OrtApis::CreateStatus(ORT_FAIL, "OrtSessionOptionsAppendExecutionProvider_Cuda: Failed to load shared library");
11551169
}
11561170

11571171
options->provider_factories.push_back(factory);
11581172
return nullptr;
1173+
API_IMPL_END
11591174
}

0 commit comments

Comments
 (0)