mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Enable model subgraph execution in OVEP and setting the OpenVINO dll's to the path from the OpenVINO pypi packge in OVEP and fix OVEP windows io buffer sample (#16147)
### Description This PR enables execution of subgraphs in OVEP and currently, when OVEP developers install the onnxruntime-openvino package on windows from pypi, they would have to additionally download OpenVINO windows binaries and run the setupvars.bat script which sets the environment PATH to locate the OV dll's. Also this PR fixes issues of OVEP windows io buffer sample. ### Motivation and Context Fix: We want to make the user experience easy for OVEP Python developers on windows platform. This fix, introduces a function add_openvino_libs_to_path at the location tools/python/util/add_openvino_win_libs.py. The above function, can be called by OVEP python users in the application code and that takes care of setting the OpenVINO dll's to the path from the OpenVINO pypi packge (openvino) which was installed. This change also makes sure that add_openvino_libs_to_path() function is added to onnxruntime python package only when it is build for OpenVINO Execution Provider for ONNXRuntime and not for default ORT python package builds. New user experience for Python OVEP developers on windows platform: step 1: pip install onnxruntime-openvino step 2: pip install openvino step 3: <Add these 2 lines in the application code> import onnxruntime.tools.add_openvino_win_libs as utils utils.add_openvino_libs_to_path() --------- Signed-off-by: MaajidKhan <n.maajid.khan@intel.com> Co-authored-by: MaajidKhan <n.maajid.khan@intel.com> Co-authored-by: Suryaprakash Shanmugam <suryaprakash.shanmugam@intel.com>
This commit is contained in:
parent
3f7f90aed0
commit
a6ce7b339f
12 changed files with 400 additions and 354 deletions
|
|
@ -880,7 +880,7 @@ if (onnxruntime_USE_OPENVINO)
|
|||
target_compile_options(onnxruntime_providers_openvino PRIVATE "-Wno-parentheses")
|
||||
endif()
|
||||
add_dependencies(onnxruntime_providers_openvino onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
||||
target_include_directories(onnxruntime_providers_openvino SYSTEM PUBLIC ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS} ${OpenVINO_INCLUDE_DIR} ${OPENVINO_INCLUDE_DIR_LIST} ${PYTHON_INCLUDE_DIRS} $ENV{OPENCL_INCS})
|
||||
target_include_directories(onnxruntime_providers_openvino SYSTEM PUBLIC ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS} ${OpenVINO_INCLUDE_DIR} ${OPENVINO_INCLUDE_DIR_LIST} ${PYTHON_INCLUDE_DIRS} $ENV{OPENCL_INCS} $ENV{OPENCL_INCS}/../../cl_headers/)
|
||||
target_link_libraries(onnxruntime_providers_openvino ${ONNXRUNTIME_PROVIDERS_SHARED} Boost::mp11 ${OPENVINO_LIB_LIST} ${ABSEIL_LIBS})
|
||||
|
||||
target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_MAJOR=${VERSION_MAJOR_PART})
|
||||
|
|
|
|||
|
|
@ -504,6 +504,12 @@ file(GLOB onnxruntime_qdq_helper_srcs CONFIGURE_DEPENDS
|
|||
${REPO_ROOT}/tools/python/util/qdq_helpers/*.py
|
||||
)
|
||||
|
||||
if (onnxruntime_USE_OPENVINO)
|
||||
file(GLOB onnxruntime_python_openvino_python_srcs CONFIGURE_DEPENDS
|
||||
${REPO_ROOT}/tools/python/util/add_openvino_win_libs.py
|
||||
)
|
||||
endif()
|
||||
|
||||
set(build_output_target onnxruntime_common)
|
||||
if(NOT onnxruntime_ENABLE_STATIC_ANALYSIS)
|
||||
add_custom_command(
|
||||
|
|
@ -630,6 +636,15 @@ add_custom_command(
|
|||
$<TARGET_FILE_DIR:${build_output_target}>
|
||||
)
|
||||
|
||||
if (onnxruntime_USE_OPENVINO)
|
||||
add_custom_command(
|
||||
TARGET onnxruntime_pybind11_state POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${onnxruntime_python_openvino_python_srcs}
|
||||
$<TARGET_FILE_DIR:${build_output_target}>/onnxruntime/tools/
|
||||
)
|
||||
endif()
|
||||
|
||||
if (onnxruntime_ENABLE_EXTERNAL_CUSTOM_OP_SCHEMAS)
|
||||
add_custom_command(
|
||||
TARGET onnxruntime_pybind11_state POST_BUILD
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#-------------------------------------------------------------------------
|
||||
# Copyright(C) 2021 Intel Corporation.
|
||||
# Copyright(C) 2021-2023 Intel Corporation.
|
||||
# SPDX-License-Identifier: MIT
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
ARG OPENVINO_VERSION=2022.3.0
|
||||
ARG OPENVINO_VERSION=2023.0.0
|
||||
|
||||
|
||||
# Build stage
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#-------------------------------------------------------------------------
|
||||
# Copyright(C) 2021 Intel Corporation.
|
||||
# Copyright(C) 2021-2023 Intel Corporation.
|
||||
# SPDX-License-Identifier: MIT
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
ARG OPENVINO_VERSION=2022.3.0
|
||||
ARG OPENVINO_VERSION=2023.0.0
|
||||
|
||||
# Build stage
|
||||
FROM openvino/ubuntu20_runtime:${OPENVINO_VERSION} AS base
|
||||
|
|
|
|||
|
|
@ -15,18 +15,18 @@ Requirements
|
|||
^^^^^^^^^^^^
|
||||
|
||||
- Ubuntu 18.04, 20.04, RHEL(CPU only) or Windows 10 - 64 bit
|
||||
- Python 3.7, 3.8 or 3.9 for Linux and only Python3.9 for Windows
|
||||
- Python 3.8, 3.9 or 3.10 for Linux and only Python3.10 for Windows
|
||||
|
||||
This package supports:
|
||||
- Intel® CPUs
|
||||
- Intel® integrated GPUs
|
||||
|
||||
``pip3 install onnxruntime-openvino==1.13.1``
|
||||
``pip3 install onnxruntime-openvino``
|
||||
|
||||
Please install OpenVINO™ PyPi Package separately for Windows.
|
||||
For installation instructions on Windows please refer to `OpenVINO™ Execution Provider for ONNX Runtime for Windows <https://github.com/intel/onnxruntime/releases/>`_.
|
||||
|
||||
**OpenVINO™ Execution Provider for ONNX Runtime** Linux Wheels comes with pre-built libraries of OpenVINO™ version 2022.2.0 eliminating the need to install OpenVINO™ separately. The OpenVINO™ libraries are prebuilt with CXX11_ABI flag set to 0.
|
||||
**OpenVINO™ Execution Provider for ONNX Runtime** Linux Wheels comes with pre-built libraries of OpenVINO™ version 2023.0.0 eliminating the need to install OpenVINO™ separately. The OpenVINO™ libraries are prebuilt with CXX11_ABI flag set to 0.
|
||||
|
||||
The package also includes module that is used by torch-ort-inference to accelerate inference for PyTorch models with OpenVINO Execution Provider.
|
||||
See `torch-ort-inference <https://github.com/pytorch/ort#accelerate-inference-for-pytorch-models-with-onnx-runtime-preview>`_ for more details.
|
||||
|
|
|
|||
|
|
@ -56,21 +56,10 @@ BasicBackend::BasicBackend(const ONNX_NAMESPACE::ModelProto& model_proto,
|
|||
exe_network_ = global_context_.ie_core.LoadNetwork(ie_cnn_network_, remote_context_, subgraph_context_.subgraph_name);
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Loaded model to the plugin";
|
||||
} else {
|
||||
#if defined(OPENVINO_2023_0)
|
||||
if (subgraph_context.precision != InferenceEngine::Precision::FP16) {
|
||||
const std::string model = model_proto.SerializeAsString();
|
||||
exe_network_ = global_context_.ie_core.LoadNetwork(model, hw_target, device_config, subgraph_context_.subgraph_name);
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Loaded model to the plugin";
|
||||
} else {
|
||||
ie_cnn_network_ = CreateOVModel(model_proto, global_context_, subgraph_context_, const_outputs_map_);
|
||||
exe_network_ = global_context_.ie_core.LoadNetwork(ie_cnn_network_, hw_target, device_config, subgraph_context_.subgraph_name);
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Loaded model to the plugin";
|
||||
}
|
||||
#else
|
||||
ie_cnn_network_ = CreateOVModel(model_proto, global_context_, subgraph_context_, const_outputs_map_);
|
||||
exe_network_ = global_context_.ie_core.LoadNetwork(ie_cnn_network_, hw_target, device_config, subgraph_context_.subgraph_name);
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Loaded model to the plugin";
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
#if defined(OPENVINO_2023_0)
|
||||
if (subgraph_context.precision != InferenceEngine::Precision::FP16 && global_context_.enable_dynamic_shapes == false) {
|
||||
|
|
@ -88,357 +77,355 @@ BasicBackend::BasicBackend(const ONNX_NAMESPACE::ModelProto& model_proto,
|
|||
LOGS_DEFAULT(INFO) << log_tag << "Loaded model to the plugin";
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
ie_cnn_network_ = CreateOVModel(model_proto, global_context_, subgraph_context_, const_outputs_map_);
|
||||
exe_network_ = global_context_.ie_core.LoadNetwork(ie_cnn_network_, hw_target, device_config, subgraph_context_.subgraph_name);
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Loaded model to the plugin";
|
||||
}
|
||||
}
|
||||
catch (const char* msg) {
|
||||
throw(msg);
|
||||
} else {
|
||||
ie_cnn_network_ = CreateOVModel(model_proto, global_context_, subgraph_context_, const_outputs_map_);
|
||||
exe_network_ = global_context_.ie_core.LoadNetwork(ie_cnn_network_, hw_target, device_config, subgraph_context_.subgraph_name);
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Loaded model to the plugin";
|
||||
}
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
|
||||
// The infer_requests_ pool will be intialized with a default value of 8 infer_request's
|
||||
// The nireq value can also be configured to any num_of_threads during runtime
|
||||
size_t nireq = global_context_.num_of_threads;
|
||||
LOGS_DEFAULT(INFO) << log_tag << "The value of nireq being used is: " << nireq;
|
||||
// The infer_requests_ pool will be intialized with a default value of 8 infer_request's
|
||||
// The nireq value can also be configured to any num_of_threads during runtime
|
||||
size_t nireq = global_context_.num_of_threads;
|
||||
LOGS_DEFAULT(INFO) << log_tag << "The value of nireq being used is: " << nireq;
|
||||
#ifndef NDEBUG
|
||||
if (openvino_ep::backend_utils::IsDebugEnabled()) {
|
||||
std::cout << "The value of nireq being used is: " << nireq << std::endl;
|
||||
}
|
||||
if (openvino_ep::backend_utils::IsDebugEnabled()) {
|
||||
std::cout << "The value of nireq being used is: " << nireq << std::endl;
|
||||
}
|
||||
#endif
|
||||
inferRequestsQueue_ = std::unique_ptr<InferRequestsQueue>(new InferRequestsQueue(exe_network_, nireq));
|
||||
}
|
||||
inferRequestsQueue_ = std::unique_ptr<InferRequestsQueue>(new InferRequestsQueue(exe_network_, nireq));
|
||||
}
|
||||
|
||||
bool BasicBackend::ValidateSubgraph(std::map<std::string, std::shared_ptr<ngraph::Node>> & const_outputs_map) {
|
||||
if (const_outputs_map.size() == subgraph_context_.output_names.size())
|
||||
subgraph_context_.is_constant = true;
|
||||
if (subgraph_context_.is_constant) {
|
||||
LOGS_DEFAULT(INFO) << log_tag << "The subgraph is a const. Directly moving to Infer stage.";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
bool BasicBackend::ValidateSubgraph(std::map<std::string, std::shared_ptr<ngraph::Node>>& const_outputs_map) {
|
||||
if (const_outputs_map.size() == subgraph_context_.output_names.size())
|
||||
subgraph_context_.is_constant = true;
|
||||
if (subgraph_context_.is_constant) {
|
||||
LOGS_DEFAULT(INFO) << log_tag << "The subgraph is a const. Directly moving to Infer stage.";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BasicBackend::PopulateConfigValue(ov::AnyMap & device_config) {
|
||||
// Set inference precision if device_type != AUTO
|
||||
// if (global_context_.device_type.find("GPU_FP16")!= std::string::npos){
|
||||
// device_config.emplace(ov::hint::inference_precision(global_context_.precision_str));
|
||||
// }
|
||||
device_config = {};
|
||||
void BasicBackend::PopulateConfigValue(ov::AnyMap& device_config) {
|
||||
// Set inference precision if device_type != AUTO
|
||||
// if (global_context_.device_type.find("GPU_FP16")!= std::string::npos){
|
||||
// device_config.emplace(ov::hint::inference_precision(global_context_.precision_str));
|
||||
// }
|
||||
device_config = {};
|
||||
#ifndef NDEBUG
|
||||
if (openvino_ep::backend_utils::IsDebugEnabled()) {
|
||||
device_config.emplace(ov::enable_profiling(true));
|
||||
}
|
||||
if (openvino_ep::backend_utils::IsDebugEnabled()) {
|
||||
device_config.emplace(ov::enable_profiling(true));
|
||||
}
|
||||
#endif
|
||||
#if defined(OPENVINO_2023_0)
|
||||
if (global_context_.device_type.find("VPUX") != std::string::npos) {
|
||||
std::pair<std::string, ov::Any> device_property;
|
||||
device_property = std::make_pair("VPUX_COMPILER_TYPE", "MLIR");
|
||||
device_config.emplace(ov::device::properties("VPUX", device_property));
|
||||
}
|
||||
#endif
|
||||
if (global_context_.device_type.find("VPUX") != std::string::npos) {
|
||||
std::pair<std::string, ov::Any> device_property;
|
||||
device_property = std::make_pair("VPUX_COMPILER_TYPE", "MLIR");
|
||||
device_config.emplace(ov::device::properties("VPUX", device_property));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void BasicBackend::EnableCaching() {
|
||||
if (!global_context_.cache_dir.empty()) {
|
||||
if (global_context_.is_wholly_supported_graph) {
|
||||
void BasicBackend::EnableCaching() {
|
||||
if (!global_context_.cache_dir.empty()) {
|
||||
if (global_context_.is_wholly_supported_graph) {
|
||||
#if defined(OPENVINO_2022_3)
|
||||
#if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
|
||||
_putenv_s("OV_GPU_CACHE_MODEL", "1");
|
||||
_putenv_s("OV_GPU_CACHE_MODEL", "1");
|
||||
#else
|
||||
setenv("OV_GPU_CACHE_MODEL", "1", 1);
|
||||
setenv("OV_GPU_CACHE_MODEL", "1", 1);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Enables Caching";
|
||||
global_context_.ie_core.SetCache(global_context_.cache_dir);
|
||||
}
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Enables Caching";
|
||||
global_context_.ie_core.SetCache(global_context_.cache_dir);
|
||||
}
|
||||
}
|
||||
|
||||
void BasicBackend::EnableGPUThrottling(ov::AnyMap & device_config) {
|
||||
if (global_context_.enable_opencl_throttling == true && global_context_.device_type.find("GPU") != std::string::npos) {
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Enabled OpenCL queue throttling for GPU device";
|
||||
device_config[GPU_CONFIG_KEY(PLUGIN_THROTTLE)] = "1";
|
||||
}
|
||||
void BasicBackend::EnableGPUThrottling(ov::AnyMap& device_config) {
|
||||
if (global_context_.enable_opencl_throttling == true && global_context_.device_type.find("GPU") != std::string::npos) {
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Enabled OpenCL queue throttling for GPU device";
|
||||
device_config[GPU_CONFIG_KEY(PLUGIN_THROTTLE)] = "1";
|
||||
}
|
||||
}
|
||||
|
||||
// Starts an asynchronous inference request for data in slice indexed by batch_slice_idx on
|
||||
// an Infer Request indexed by infer_req_idx
|
||||
void BasicBackend::StartAsyncInference(Ort::KernelContext & context, OVInferRequestPtr infer_request) {
|
||||
try {
|
||||
auto graph_input_info = exe_network_.Get().inputs();
|
||||
int input_idx = 0;
|
||||
for (auto input_info_iter = graph_input_info.begin();
|
||||
input_info_iter != graph_input_info.end(); ++input_info_iter) {
|
||||
auto input_names = input_info_iter->get_names();
|
||||
std::string onnx_input_name;
|
||||
std::string input_name;
|
||||
// use names retrieved from original ONNX model to assign the right onnx input name for the graph
|
||||
for (auto it = subgraph_context_.input_names.begin(); it != subgraph_context_.input_names.end(); ++it) {
|
||||
if (it->second == input_idx) {
|
||||
onnx_input_name = it->first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// using the input name retrieved from ONNX original to match with the input names returned by OV tensors
|
||||
if (input_names.find(onnx_input_name) != input_names.end()) {
|
||||
input_name = onnx_input_name;
|
||||
} else {
|
||||
throw(log_tag + "Input names mismatch between OpenVINO and ONNX. " + onnx_input_name + " doesn't exist in the list of OpenVINO input tensor names");
|
||||
}
|
||||
size_t batch_slice_idx = 0;
|
||||
if (subgraph_context_.has_dynamic_input_shape &&
|
||||
global_context_.enable_dynamic_shapes == true &&
|
||||
(global_context_.device_type.find("CPU") != std::string::npos ||
|
||||
global_context_.device_type.find("GPU") != std::string::npos)) {
|
||||
auto tensor = context.GetInput(subgraph_context_.input_names.at(input_name));
|
||||
auto tensor_info = tensor.GetTensorTypeAndShapeInfo();
|
||||
auto tensor_shape = tensor_info.GetShape();
|
||||
auto tensor_size = tensor_shape.size();
|
||||
auto tensor_iter = 0;
|
||||
ov::Shape input_tensor_shape = ov::Shape(tensor_size, 0);
|
||||
for (auto i = tensor_shape.begin(); i != tensor_shape.end(); ++i) {
|
||||
input_tensor_shape[tensor_iter] = *i;
|
||||
tensor_iter += 1;
|
||||
}
|
||||
auto input = ie_cnn_network_->get_parameters().at(input_idx);
|
||||
OVTensorPtr tensor_ptr = std::make_shared<ov::Tensor>(input->get_element_type(), input_tensor_shape);
|
||||
FillInputBlob(tensor_ptr, batch_slice_idx, input_name, context, subgraph_context_);
|
||||
try {
|
||||
infer_request->SetTensor(input_name, tensor_ptr);
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
} else {
|
||||
OVTensorPtr graph_input_blob;
|
||||
try {
|
||||
graph_input_blob = infer_request->GetTensor(input_name);
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
FillInputBlob(graph_input_blob, batch_slice_idx, input_name, context, subgraph_context_);
|
||||
}
|
||||
input_idx++;
|
||||
}
|
||||
// Start Async inference
|
||||
infer_request->StartAsync();
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IO_BUFFER_ENABLED
|
||||
// Wait for Remote Aynchronous inference completion
|
||||
void BasicBackend::StartRemoteAsyncInference(Ort::KernelContext & context, OVInferRequestPtr infer_request) {
|
||||
try {
|
||||
auto graph_input_info = exe_network_.Get().inputs();
|
||||
int input_idx = 0;
|
||||
for (auto input_info_iter = graph_input_info.begin();
|
||||
input_info_iter != graph_input_info.end(); ++input_info_iter) {
|
||||
auto input_names = input_info_iter->get_names();
|
||||
std::string onnx_input_name;
|
||||
std::string input_name;
|
||||
// use names retrieved from original ONNX model to assign the right onnx input name for the graph
|
||||
for (auto it = subgraph_context_.input_names.begin(); it != subgraph_context_.input_names.end(); ++it) {
|
||||
if (it->second == input_idx) {
|
||||
onnx_input_name = it->first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// using the input name retrieved from ONNX original to match with the input names returned by OV tensors
|
||||
if (input_names.find(onnx_input_name) != input_names.end()) {
|
||||
input_name = onnx_input_name;
|
||||
} else {
|
||||
throw(log_tag + "Input names mismatch between OpenVINO and ONNX. " + onnx_input_name + " doesn't exist in the list of OpenVINO input tensor names");
|
||||
}
|
||||
input_idx++;
|
||||
// Kernel Context Input Buffer
|
||||
const auto tensor = context.GetInput(subgraph_context_.input_names.at(input_name));
|
||||
// If the ORTValue wraps a device pointer
|
||||
auto mem_info = tensor.GetTensorMemoryInfo();
|
||||
if (mem_info.GetAllocatorName() == OpenVINO_GPU) {
|
||||
// Get the shared buffer pointer
|
||||
const void* tensor_data = tensor.GetTensorRawData();
|
||||
const cl::Buffer* shared_buffer_const = static_cast<const cl::Buffer*>(tensor_data);
|
||||
// Create an Input Remote Blob
|
||||
auto input = ie_cnn_network_->get_parameters().at(0);
|
||||
auto remote_blob = remote_context_->create_tensor(input->get_element_type(), input->get_shape(), *shared_buffer_const);
|
||||
ov::Tensor tensor = static_cast<ov::Tensor>(remote_blob);
|
||||
OVTensorPtr tensor_ptr = std::make_shared<ov::Tensor>(tensor);
|
||||
infer_request->SetTensor(input_name, tensor_ptr);
|
||||
} else {
|
||||
OVTensorPtr graph_input_blob;
|
||||
graph_input_blob = infer_request->GetTensor(input_name);
|
||||
size_t batch_slice_idx = 0;
|
||||
FillInputBlob(graph_input_blob, batch_slice_idx, input_name, context, subgraph_context_);
|
||||
// Starts an asynchronous inference request for data in slice indexed by batch_slice_idx on
|
||||
// an Infer Request indexed by infer_req_idx
|
||||
void BasicBackend::StartAsyncInference(Ort::KernelContext& context, OVInferRequestPtr infer_request) {
|
||||
try {
|
||||
auto graph_input_info = exe_network_.Get().inputs();
|
||||
int input_idx = 0;
|
||||
for (auto input_info_iter = graph_input_info.begin();
|
||||
input_info_iter != graph_input_info.end(); ++input_info_iter) {
|
||||
auto input_names = input_info_iter->get_names();
|
||||
std::string onnx_input_name;
|
||||
std::string input_name;
|
||||
// use names retrieved from original ONNX model to assign the right onnx input name for the graph
|
||||
for (auto it = subgraph_context_.input_names.begin(); it != subgraph_context_.input_names.end(); ++it) {
|
||||
if (it->second == input_idx) {
|
||||
onnx_input_name = it->first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the output blob as remote blob
|
||||
auto graph_output_info = exe_network_.Get().outputs();
|
||||
for (auto output_info_iter = graph_output_info.begin();
|
||||
output_info_iter != graph_output_info.end(); ++output_info_iter) {
|
||||
auto output_names = output_info_iter->get_names();
|
||||
std::string onnx_output_name;
|
||||
std::string output_name;
|
||||
bool output_name_found = false;
|
||||
// using the output name retrieved from ONNX original to match with the output names returned by OV tensors
|
||||
for (auto it = subgraph_context_.output_names.begin(); it != subgraph_context_.output_names.end(); ++it) {
|
||||
onnx_output_name = it->first;
|
||||
if (output_names.find(onnx_output_name) != output_names.end()) {
|
||||
// Assigning the output_name
|
||||
output_name = it->first;
|
||||
output_name_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!output_name_found) {
|
||||
throw std::string(log_tag + "Output names mismatch between OpenVINO and ONNX. [ONNX Output: ] " + onnx_output_name + " doesn't exist in the list of OpenVINO output tensor names");
|
||||
}
|
||||
|
||||
size_t batch_size = 1;
|
||||
auto tensor = GetOutputTensor(context, batch_size, infer_request, output_name, subgraph_context_.output_names);
|
||||
auto mem_info = tensor.GetTensorMemoryInfo();
|
||||
// Check if ORT Value wraps a device pointer
|
||||
if (mem_info.GetAllocatorName() == OpenVINO_GPU) {
|
||||
const void* tensor_data = tensor.GetTensorRawData();
|
||||
const cl::Buffer* shared_buffer_const = static_cast<const cl::Buffer*>(tensor_data);
|
||||
// Create a shared Blob, set the Infer Request Output Blob
|
||||
auto output = ie_cnn_network_->get_results().at(0);
|
||||
auto remote_tensor = remote_context_->create_tensor(output->get_element_type(), output->get_shape(), *shared_buffer_const);
|
||||
ov::Tensor tensor = static_cast<ov::Tensor>(remote_tensor);
|
||||
OVTensorPtr tensor_ptr = std::make_shared<ov::Tensor>(tensor);
|
||||
try {
|
||||
infer_request->SetTensor(output_name, tensor_ptr);
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
}
|
||||
// using the input name retrieved from ONNX original to match with the input names returned by OV tensors
|
||||
if (input_names.find(onnx_input_name) != input_names.end()) {
|
||||
input_name = onnx_input_name;
|
||||
} else {
|
||||
throw(log_tag + "Input names mismatch between OpenVINO and ONNX. " + onnx_input_name + " doesn't exist in the list of OpenVINO input tensor names");
|
||||
}
|
||||
|
||||
// Start Async inference
|
||||
infer_request->StartAsync();
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Wait for asynchronous inference completion on an Infer Request object indexed by infer_req_idx
|
||||
// and copy the results into a slice location within the batched output buffer indexed by batch_slice_idx
|
||||
void BasicBackend::CompleteAsyncInference(Ort::KernelContext & context, OVInferRequestPtr infer_request) {
|
||||
// Wait for Async inference completion
|
||||
try {
|
||||
infer_request->WaitRequest();
|
||||
auto graph_output_info = exe_network_.Get().outputs();
|
||||
for (auto output_info_iter = graph_output_info.begin();
|
||||
output_info_iter != graph_output_info.end(); ++output_info_iter) {
|
||||
OVTensorPtr graph_output_blob;
|
||||
auto output_names = output_info_iter->get_names();
|
||||
std::string onnx_output_name;
|
||||
std::string output_name;
|
||||
bool output_name_found = false;
|
||||
// using the output name retrieved from ONNX original to match with the output names returned by OV tensors
|
||||
for (auto it = subgraph_context_.output_names.begin(); it != subgraph_context_.output_names.end(); ++it) {
|
||||
onnx_output_name = it->first;
|
||||
if (output_names.find(onnx_output_name) != output_names.end()) {
|
||||
// Assigning the output_name
|
||||
output_name = it->first;
|
||||
output_name_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!output_name_found) {
|
||||
throw(log_tag +
|
||||
"Output names mismatch between OpenVINO and ONNX. "
|
||||
"[ONNX Output: ] " +
|
||||
onnx_output_name +
|
||||
" doesn't exist in the "
|
||||
"list of OpenVINO output tensor names");
|
||||
size_t batch_slice_idx = 0;
|
||||
if (subgraph_context_.has_dynamic_input_shape &&
|
||||
global_context_.enable_dynamic_shapes == true &&
|
||||
(global_context_.device_type.find("CPU") != std::string::npos ||
|
||||
global_context_.device_type.find("GPU") != std::string::npos)) {
|
||||
auto tensor = context.GetInput(subgraph_context_.input_names.at(input_name));
|
||||
auto tensor_info = tensor.GetTensorTypeAndShapeInfo();
|
||||
auto tensor_shape = tensor_info.GetShape();
|
||||
auto tensor_size = tensor_shape.size();
|
||||
auto tensor_iter = 0;
|
||||
ov::Shape input_tensor_shape = ov::Shape(tensor_size, 0);
|
||||
for (auto i = tensor_shape.begin(); i != tensor_shape.end(); ++i) {
|
||||
input_tensor_shape[tensor_iter] = *i;
|
||||
tensor_iter += 1;
|
||||
}
|
||||
auto input = ie_cnn_network_->get_parameters().at(input_idx);
|
||||
OVTensorPtr tensor_ptr = std::make_shared<ov::Tensor>(input->get_element_type(), input_tensor_shape);
|
||||
FillInputBlob(tensor_ptr, batch_slice_idx, input_name, context, subgraph_context_);
|
||||
try {
|
||||
graph_output_blob = infer_request->GetTensor(output_name);
|
||||
infer_request->SetTensor(input_name, tensor_ptr);
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
size_t batch_size = 1;
|
||||
auto output_tensor = GetOutputTensor(context, batch_size, infer_request, output_name, subgraph_context_.output_names);
|
||||
auto mem_info = output_tensor.GetTensorMemoryInfo();
|
||||
if (mem_info.GetAllocatorName() == OpenVINO_GPU) {
|
||||
return;
|
||||
} else {
|
||||
size_t batch_slice = 0;
|
||||
FillOutputBlob(graph_output_blob, output_tensor, batch_slice);
|
||||
} else {
|
||||
OVTensorPtr graph_input_blob;
|
||||
try {
|
||||
graph_input_blob = infer_request->GetTensor(input_name);
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
FillInputBlob(graph_input_blob, batch_slice_idx, input_name, context, subgraph_context_);
|
||||
}
|
||||
|
||||
if (!const_outputs_map_.empty()) {
|
||||
for (auto item : const_outputs_map_) {
|
||||
auto out_name = item.first;
|
||||
auto node = item.second;
|
||||
auto output_tensor = GetOutputTensor(context, out_name, subgraph_context_.output_names, node);
|
||||
auto mem_info = output_tensor.GetTensorMemoryInfo();
|
||||
if (mem_info.GetAllocatorName() == OpenVINO_GPU) {
|
||||
throw(log_tag + "IO Buffering is not supported for constant subgraphs");
|
||||
} else {
|
||||
FillOutputsWithConstantData(node, output_tensor);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
input_idx++;
|
||||
}
|
||||
// Start Async inference
|
||||
infer_request->StartAsync();
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void BasicBackend::Infer(OrtKernelContext * ctx) {
|
||||
// Preliminary Thread safety mechanism
|
||||
// currently allows a maximum of 8 Infer request's to parallel execute at the same time
|
||||
Ort::KernelContext context(ctx);
|
||||
#ifdef IO_BUFFER_ENABLED
|
||||
// Wait for Remote Aynchronous inference completion
|
||||
void BasicBackend::StartRemoteAsyncInference(Ort::KernelContext& context, OVInferRequestPtr infer_request) {
|
||||
try {
|
||||
auto graph_input_info = exe_network_.Get().inputs();
|
||||
int input_idx = 0;
|
||||
for (auto input_info_iter = graph_input_info.begin();
|
||||
input_info_iter != graph_input_info.end(); ++input_info_iter) {
|
||||
auto input_names = input_info_iter->get_names();
|
||||
std::string onnx_input_name;
|
||||
std::string input_name;
|
||||
// use names retrieved from original ONNX model to assign the right onnx input name for the graph
|
||||
for (auto it = subgraph_context_.input_names.begin(); it != subgraph_context_.input_names.end(); ++it) {
|
||||
if (it->second == input_idx) {
|
||||
onnx_input_name = it->first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// using the input name retrieved from ONNX original to match with the input names returned by OV tensors
|
||||
if (input_names.find(onnx_input_name) != input_names.end()) {
|
||||
input_name = onnx_input_name;
|
||||
} else {
|
||||
throw(log_tag + "Input names mismatch between OpenVINO and ONNX. " + onnx_input_name + " doesn't exist in the list of OpenVINO input tensor names");
|
||||
}
|
||||
input_idx++;
|
||||
// Kernel Context Input Buffer
|
||||
const auto tensor = context.GetInput(subgraph_context_.input_names.at(input_name));
|
||||
// If the ORTValue wraps a device pointer
|
||||
auto mem_info = tensor.GetTensorMemoryInfo();
|
||||
if (mem_info.GetAllocatorName() == OpenVINO_GPU) {
|
||||
// Get the shared buffer pointer
|
||||
const void* tensor_data = tensor.GetTensorRawData();
|
||||
const cl::Buffer* shared_buffer_const = static_cast<const cl::Buffer*>(tensor_data);
|
||||
// Create an Input Remote Blob
|
||||
auto input = ie_cnn_network_->get_parameters().at(0);
|
||||
auto remote_blob = remote_context_->create_tensor(input->get_element_type(), input->get_shape(), *shared_buffer_const);
|
||||
ov::Tensor tensor = static_cast<ov::Tensor>(remote_blob);
|
||||
OVTensorPtr tensor_ptr = std::make_shared<ov::Tensor>(tensor);
|
||||
infer_request->SetTensor(input_name, tensor_ptr);
|
||||
} else {
|
||||
OVTensorPtr graph_input_blob;
|
||||
graph_input_blob = infer_request->GetTensor(input_name);
|
||||
size_t batch_slice_idx = 0;
|
||||
FillInputBlob(graph_input_blob, batch_slice_idx, input_name, context, subgraph_context_);
|
||||
}
|
||||
}
|
||||
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Running graph " << subgraph_context_.subgraph_name;
|
||||
LOGS_DEFAULT(INFO) << log_tag << "In Infer";
|
||||
// Set the output blob as remote blob
|
||||
auto graph_output_info = exe_network_.Get().outputs();
|
||||
for (auto output_info_iter = graph_output_info.begin();
|
||||
output_info_iter != graph_output_info.end(); ++output_info_iter) {
|
||||
auto output_names = output_info_iter->get_names();
|
||||
std::string onnx_output_name;
|
||||
std::string output_name;
|
||||
bool output_name_found = false;
|
||||
// using the output name retrieved from ONNX original to match with the output names returned by OV tensors
|
||||
for (auto it = subgraph_context_.output_names.begin(); it != subgraph_context_.output_names.end(); ++it) {
|
||||
onnx_output_name = it->first;
|
||||
if (output_names.find(onnx_output_name) != output_names.end()) {
|
||||
// Assigning the output_name
|
||||
output_name = it->first;
|
||||
output_name_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!output_name_found) {
|
||||
throw std::string(log_tag + "Output names mismatch between OpenVINO and ONNX. [ONNX Output: ] " + onnx_output_name + " doesn't exist in the list of OpenVINO output tensor names");
|
||||
}
|
||||
|
||||
if (subgraph_context_.is_constant) {
|
||||
size_t batch_size = 1;
|
||||
auto tensor = GetOutputTensor(context, batch_size, infer_request, output_name, subgraph_context_.output_names);
|
||||
auto mem_info = tensor.GetTensorMemoryInfo();
|
||||
// Check if ORT Value wraps a device pointer
|
||||
if (mem_info.GetAllocatorName() == OpenVINO_GPU) {
|
||||
const void* tensor_data = tensor.GetTensorRawData();
|
||||
const cl::Buffer* shared_buffer_const = static_cast<const cl::Buffer*>(tensor_data);
|
||||
// Create a shared Blob, set the Infer Request Output Blob
|
||||
auto output = ie_cnn_network_->get_results().at(0);
|
||||
auto remote_tensor = remote_context_->create_tensor(output->get_element_type(), output->get_shape(), *shared_buffer_const);
|
||||
ov::Tensor tensor = static_cast<ov::Tensor>(remote_tensor);
|
||||
OVTensorPtr tensor_ptr = std::make_shared<ov::Tensor>(tensor);
|
||||
try {
|
||||
infer_request->SetTensor(output_name, tensor_ptr);
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start Async inference
|
||||
infer_request->StartAsync();
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Wait for asynchronous inference completion on an Infer Request object indexed by infer_req_idx
|
||||
// and copy the results into a slice location within the batched output buffer indexed by batch_slice_idx
|
||||
void BasicBackend::CompleteAsyncInference(Ort::KernelContext& context, OVInferRequestPtr infer_request) {
|
||||
// Wait for Async inference completion
|
||||
try {
|
||||
infer_request->WaitRequest();
|
||||
auto graph_output_info = exe_network_.Get().outputs();
|
||||
for (auto output_info_iter = graph_output_info.begin();
|
||||
output_info_iter != graph_output_info.end(); ++output_info_iter) {
|
||||
OVTensorPtr graph_output_blob;
|
||||
auto output_names = output_info_iter->get_names();
|
||||
std::string onnx_output_name;
|
||||
std::string output_name;
|
||||
bool output_name_found = false;
|
||||
// using the output name retrieved from ONNX original to match with the output names returned by OV tensors
|
||||
for (auto it = subgraph_context_.output_names.begin(); it != subgraph_context_.output_names.end(); ++it) {
|
||||
onnx_output_name = it->first;
|
||||
if (output_names.find(onnx_output_name) != output_names.end()) {
|
||||
// Assigning the output_name
|
||||
output_name = it->first;
|
||||
output_name_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!output_name_found) {
|
||||
throw(log_tag +
|
||||
"Output names mismatch between OpenVINO and ONNX. "
|
||||
"[ONNX Output: ] " +
|
||||
onnx_output_name +
|
||||
" doesn't exist in the "
|
||||
"list of OpenVINO output tensor names");
|
||||
}
|
||||
try {
|
||||
graph_output_blob = infer_request->GetTensor(output_name);
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
size_t batch_size = 1;
|
||||
auto output_tensor = GetOutputTensor(context, batch_size, infer_request, output_name, subgraph_context_.output_names);
|
||||
auto mem_info = output_tensor.GetTensorMemoryInfo();
|
||||
if (mem_info.GetAllocatorName() == OpenVINO_GPU) {
|
||||
return;
|
||||
} else {
|
||||
size_t batch_slice = 0;
|
||||
FillOutputBlob(graph_output_blob, output_tensor, batch_slice);
|
||||
}
|
||||
}
|
||||
|
||||
if (!const_outputs_map_.empty()) {
|
||||
for (auto item : const_outputs_map_) {
|
||||
auto out_name = item.first;
|
||||
auto node = item.second;
|
||||
try {
|
||||
auto output_tensor = GetOutputTensor(context, out_name, subgraph_context_.output_names, node);
|
||||
auto output_tensor = GetOutputTensor(context, out_name, subgraph_context_.output_names, node);
|
||||
auto mem_info = output_tensor.GetTensorMemoryInfo();
|
||||
if (mem_info.GetAllocatorName() == OpenVINO_GPU) {
|
||||
throw(log_tag + "IO Buffering is not supported for constant subgraphs");
|
||||
} else {
|
||||
FillOutputsWithConstantData(node, output_tensor);
|
||||
} catch (std::string const& msg) {
|
||||
throw msg;
|
||||
}
|
||||
}
|
||||
// Get Output tensors
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Inference successful";
|
||||
// Enable CI Logs
|
||||
if (IsCILogEnabled()) {
|
||||
std::cout << "Inference successful" << std::endl;
|
||||
}
|
||||
}
|
||||
} catch (const char* msg) {
|
||||
throw(msg);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Requesting for an idle infer_request from a pool of infer_requests_
|
||||
OVInferRequestPtr infer_request;
|
||||
infer_request = inferRequestsQueue_->getIdleRequest();
|
||||
void BasicBackend::Infer(OrtKernelContext* ctx) {
|
||||
// Preliminary Thread safety mechanism
|
||||
// currently allows a maximum of 8 Infer request's to parallel execute at the same time
|
||||
Ort::KernelContext context(ctx);
|
||||
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Running graph " << subgraph_context_.subgraph_name;
|
||||
LOGS_DEFAULT(INFO) << log_tag << "In Infer";
|
||||
|
||||
if (subgraph_context_.is_constant) {
|
||||
for (auto item : const_outputs_map_) {
|
||||
auto out_name = item.first;
|
||||
auto node = item.second;
|
||||
try {
|
||||
auto output_tensor = GetOutputTensor(context, out_name, subgraph_context_.output_names, node);
|
||||
FillOutputsWithConstantData(node, output_tensor);
|
||||
} catch (std::string const& msg) {
|
||||
throw msg;
|
||||
}
|
||||
}
|
||||
// Get Output tensors
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Inference successful";
|
||||
// Enable CI Logs
|
||||
if (IsCILogEnabled()) {
|
||||
std::cout << "Inference successful" << std::endl;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Requesting for an idle infer_request from a pool of infer_requests_
|
||||
OVInferRequestPtr infer_request;
|
||||
infer_request = inferRequestsQueue_->getIdleRequest();
|
||||
|
||||
#ifdef IO_BUFFER_ENABLED
|
||||
if ((global_context_.device_type.find("GPU") != std::string::npos) &&
|
||||
(global_context_.context != nullptr) &&
|
||||
(openvino_ep::BackendManager::GetGlobalContext().is_wholly_supported_graph)) {
|
||||
try {
|
||||
StartRemoteAsyncInference(context, infer_request);
|
||||
} catch (std::string const& msg) {
|
||||
throw msg;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
StartAsyncInference(context, infer_request);
|
||||
} catch (std::string const& msg) {
|
||||
throw msg;
|
||||
}
|
||||
if ((global_context_.device_type.find("GPU") != std::string::npos) &&
|
||||
(global_context_.context != nullptr) &&
|
||||
(openvino_ep::BackendManager::GetGlobalContext().is_wholly_supported_graph)) {
|
||||
try {
|
||||
StartRemoteAsyncInference(context, infer_request);
|
||||
} catch (std::string const& msg) {
|
||||
throw msg;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
StartAsyncInference(context, infer_request);
|
||||
} catch (std::string const& msg) {
|
||||
throw msg;
|
||||
}
|
||||
}
|
||||
#else
|
||||
try {
|
||||
StartAsyncInference(context, infer_request);
|
||||
|
|
@ -446,32 +433,32 @@ BasicBackend::BasicBackend(const ONNX_NAMESPACE::ModelProto& model_proto,
|
|||
throw msg;
|
||||
}
|
||||
#endif
|
||||
try {
|
||||
CompleteAsyncInference(context, infer_request);
|
||||
} catch (std::string const& msg) {
|
||||
throw msg;
|
||||
}
|
||||
try {
|
||||
CompleteAsyncInference(context, infer_request);
|
||||
} catch (std::string const& msg) {
|
||||
throw msg;
|
||||
}
|
||||
|
||||
// Get Output tensors
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Inference successful";
|
||||
// Enable CI Logs
|
||||
if (IsCILogEnabled()) {
|
||||
std::cout << "Inference successful" << std::endl;
|
||||
}
|
||||
// Get Output tensors
|
||||
LOGS_DEFAULT(INFO) << log_tag << "Inference successful";
|
||||
// Enable CI Logs
|
||||
if (IsCILogEnabled()) {
|
||||
std::cout << "Inference successful" << std::endl;
|
||||
}
|
||||
|
||||
// Once the inference is completed, the infer_request becomes free and is placed back into pool of infer_requests_
|
||||
inferRequestsQueue_->putIdleRequest(infer_request);
|
||||
// Once the inference is completed, the infer_request becomes free and is placed back into pool of infer_requests_
|
||||
inferRequestsQueue_->putIdleRequest(infer_request);
|
||||
#ifndef NDEBUG
|
||||
#ifndef IO_BUFFER_ENABLED // Printing performance counts is disabled when IO_BUFFER_ENABLED
|
||||
if (openvino_ep::backend_utils::IsDebugEnabled()) {
|
||||
inferRequestsQueue_->printstatus(); // Printing the elements of infer_requests_ vector pool only in debug mode
|
||||
std::string& hw_target = (global_context_.device_id != "") ? global_context_.device_id : global_context_.device_type;
|
||||
printPerformanceCounts(infer_request, std::cout, hw_target);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (openvino_ep::backend_utils::IsDebugEnabled()) {
|
||||
inferRequestsQueue_->printstatus(); // Printing the elements of infer_requests_ vector pool only in debug mode
|
||||
std::string& hw_target = (global_context_.device_id != "") ? global_context_.device_id : global_context_.device_type;
|
||||
printPerformanceCounts(infer_request, std::cout, hw_target);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openvino_ep
|
||||
} // namespace onnxruntime
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ std::vector<std::unique_ptr<ComputeCapability>> GetCapability::Execute() {
|
|||
std::vector<std::unique_ptr<ComputeCapability>> result;
|
||||
|
||||
// Check if it is a subgraph
|
||||
if (graph_viewer_.IsSubgraph()) {
|
||||
if (graph_viewer_.IsSubgraph() && graph_viewer_.Name() == "tf2onnx") {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ std::set<std::string> ops_supported_only_in_model = {
|
|||
"OneHot",
|
||||
"Pad",
|
||||
"QuantizeLinear",
|
||||
"RandomNormalLike",
|
||||
"Range",
|
||||
"ReduceMin",
|
||||
"Resize",
|
||||
|
|
@ -57,13 +58,14 @@ std::set<std::string> ops_supported_only_in_model = {
|
|||
"Slice",
|
||||
"Split",
|
||||
"Tile",
|
||||
"TopK"};
|
||||
"TopK",
|
||||
"Trilu"};
|
||||
|
||||
// Ops which are supported as functions (as composite ops)
|
||||
std::set<std::string> ops_supported_as_function = {
|
||||
"LessOrEqual",
|
||||
"GreaterOrEqual",
|
||||
};
|
||||
"LayerNormalization"};
|
||||
|
||||
std::vector<SupportedOp> supported_op_mode = {
|
||||
{"Abs", V_2020_4, {"CPU", "GPU"}},
|
||||
|
|
@ -160,6 +162,7 @@ std::vector<SupportedOp> supported_op_mode = {
|
|||
{"InstanceNormalization", V_2023_0, {"VPUX"}},
|
||||
{"HardSigmoid", V_2020_4, {"CPU", "GPU"}},
|
||||
{"HardMax", V_2022_1, {"CPU", "GPU"}},
|
||||
{"LayerNormalization", V_2023_0, {"CPU", "GPU"}},
|
||||
{"LeakyRelu", V_2020_4, {"CPU", "GPU"}},
|
||||
{"LeakyRelu", V_2023_0, {"VPUX"}},
|
||||
{"Less", V_2020_4, {"CPU", "GPU"}},
|
||||
|
|
@ -205,6 +208,7 @@ std::vector<SupportedOp> supported_op_mode = {
|
|||
{"QLinearMatMul", V_2022_3, {"CPU"}},
|
||||
{"QuantizeLinear", V_2021_4, {"CPU", "GPU"}},
|
||||
{"QuantizeLinear", V_2023_0, {"VPUX"}},
|
||||
{"RandomNormalLike", V_2023_0, {"CPU", "GPU"}},
|
||||
{"Range", V_2022_1, {"CPU", "GPU"}},
|
||||
{"Range", V_2023_0, {"VPUX"}},
|
||||
{"Reciprocal", V_2020_4, {"CPU", "GPU"}},
|
||||
|
|
@ -278,6 +282,7 @@ std::vector<SupportedOp> supported_op_mode = {
|
|||
{"Tile", V_2023_0, {"VPUX"}},
|
||||
{"Transpose", V_2020_4, {"CPU", "GPU"}},
|
||||
{"Transpose", V_2023_0, {"VPUX"}},
|
||||
{"Trilu", V_2023_0, {"CPU", "GPU"}},
|
||||
{"TopK", V_2020_4, {"CPU", "GPU"}},
|
||||
{"TopK", V_2023_0, {"VPUX"}},
|
||||
{"Unsqueeze", V_2020_4, {"CPU", "GPU"}},
|
||||
|
|
@ -590,7 +595,7 @@ void DataOps::populate_op_mode_supported() {
|
|||
op_list_.insert({"PRelu", obj});
|
||||
}
|
||||
{
|
||||
UnsupportedOpMode obj = {{V_2022_1, V_2022_2, V_2022_3},
|
||||
UnsupportedOpMode obj = {{V_2022_1, V_2022_2, V_2022_3, V_2023_0},
|
||||
[this](const Node* node, const InitializedTensorSet&) {
|
||||
const auto& input_arg = node->InputDefs()[1];
|
||||
auto shape = input_arg->Shape();
|
||||
|
|
@ -701,7 +706,7 @@ void DataOps::populate_op_mode_supported() {
|
|||
op_list_.insert({"Squeeze", obj});
|
||||
}
|
||||
{
|
||||
UnsupportedOpMode obj = {{V_2022_1, V_2022_2, V_2022_3},
|
||||
UnsupportedOpMode obj = {{V_2022_1, V_2022_2, V_2022_3, V_2023_0},
|
||||
[this](const Node* node, const InitializedTensorSet&) {
|
||||
// If the operator is unsqueeze
|
||||
// If axes is an input, then we cannot produce a static graph. Conversion fails in convert_function_to_cnn_network.
|
||||
|
|
@ -715,7 +720,7 @@ void DataOps::populate_op_mode_supported() {
|
|||
op_list_.insert({"Unsqueeze", obj});
|
||||
}
|
||||
{
|
||||
UnsupportedOpMode obj = {{V_2022_1, V_2022_2, V_2022_3},
|
||||
UnsupportedOpMode obj = {{V_2022_1, V_2022_2, V_2022_3, V_2023_0},
|
||||
[this](const Node* node, const InitializedTensorSet&) {
|
||||
// check for attributes
|
||||
auto& upsample_attr = node->GetAttributes();
|
||||
|
|
@ -732,7 +737,7 @@ void DataOps::populate_op_mode_supported() {
|
|||
auto shape = x_arg->Shape();
|
||||
if (shape != nullptr) {
|
||||
// input tensor rank cannot be of one dimension
|
||||
if (shape->dim_size() == 1) {
|
||||
if (shape->dim_size() == 1 || shape->dim_size() == 4) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -930,7 +930,7 @@ TEST(Loop, PassThroughSubgraphInputNoTypeOrShape) {
|
|||
test.AddOutput<float>("loop_var_0_final", {1}, {123.f});
|
||||
|
||||
// Disable TensorRT on unsupported data type BOOL
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider});
|
||||
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider, kOpenVINOExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(Loop, BugFixIssue4031_implicit_input_handling) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ struct RunOptions {
|
|||
bool add_bad_shape = false;
|
||||
bool mixed_execution_providers = false;
|
||||
// Disable TensorRT because its parser fails, and it can't handle unknown dimensions
|
||||
std::unordered_set<std::string> excluded_provider_types{kTensorrtExecutionProvider};
|
||||
std::unordered_set<std::string> excluded_provider_types{kTensorrtExecutionProvider, kOpenVINOExecutionProvider};
|
||||
};
|
||||
|
||||
static common::Status CreateSubgraph(Graph& graph, RunOptions& options, const std::string& failure_message = "");
|
||||
|
|
|
|||
|
|
@ -427,7 +427,11 @@
|
|||
"^test_training_dropout_mask", // Runs but there's accuracy mismatch
|
||||
"^test_training_dropout_default", // Runs but there's accuracy mismatch
|
||||
"^test_center_crop_pad_crop_negative_axes_hwc*", // failed due to new types or shape infer with negative axis for CenterCropPad.
|
||||
"^test_center_crop_pad_crop_negative_axes_hwc_expanded*" // failed due to new types or shape infer with negative axis for CenterCropPad.
|
||||
"^test_center_crop_pad_crop_negative_axes_hwc_expanded*", // failed due to new types or shape infer with negative axis for CenterCropPad.
|
||||
"test_range_int32_type_negative_delta_expanded_cpu", // Error but not a failure.
|
||||
"test_range_float_type_positive_delta_expanded_cpu", // Error but not a failure.
|
||||
"test_scan_sum_cpu", // Disabled due to output mismatch with tolerance.
|
||||
"test_scan9_sum_cpu" // Disabled due to output mismatch with tolerance.
|
||||
],
|
||||
"current_failing_tests_OPENVINO_opset18": [
|
||||
// pending opset 18 support, RUNTIME_EXCEPTION : Encountered unknown exception in Initialize()
|
||||
|
|
|
|||
35
tools/python/util/add_openvino_win_libs.py
Normal file
35
tools/python/util/add_openvino_win_libs.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# Copyright (C) 2022-2023 Intel Corporation
|
||||
# Licensed under the MIT License
|
||||
|
||||
import os
|
||||
import site
|
||||
import sys
|
||||
|
||||
|
||||
def add_openvino_libs_to_path() -> None:
|
||||
"""Adds OpenVINO libraries to the PATH environment variable on Windows."""
|
||||
if sys.platform == "win32":
|
||||
# Installer, pip installs openvino dlls to the different directories
|
||||
# and those paths need to be visible to the openvino-ep modules
|
||||
#
|
||||
# If you're using a custom installation of openvino,
|
||||
# add the location of openvino dlls to your system PATH.
|
||||
openvino_libs = []
|
||||
# looking for the libs in the pip installation path.
|
||||
if os.path.isdir(os.path.join(site.getsitepackages()[1], "openvino", "libs")):
|
||||
openvino_libs.append(os.path.join(site.getsitepackages()[1], "openvino", "libs"))
|
||||
else:
|
||||
# setupvars.bat script set all libs paths to OPENVINO_LIB_PATHS environment variable.
|
||||
openvino_libs_installer = os.getenv("OPENVINO_LIB_PATHS")
|
||||
if openvino_libs_installer:
|
||||
openvino_libs.extend(openvino_libs_installer.split(";"))
|
||||
else:
|
||||
sys.exit(
|
||||
"Error: Please set the OPENVINO_LIB_PATHS environment variable. "
|
||||
"If you use an install package, please, run setupvars.bat"
|
||||
)
|
||||
for lib in openvino_libs:
|
||||
lib_path = os.path.join(os.path.dirname(__file__), lib)
|
||||
if os.path.isdir(lib_path):
|
||||
os.environ["PATH"] = os.path.abspath(lib_path) + ";" + os.environ["PATH"]
|
||||
os.add_dll_directory(os.path.abspath(lib_path))
|
||||
Loading…
Reference in a new issue