diff --git a/onnxruntime/core/providers/openvino/backend_utils.cc b/onnxruntime/core/providers/openvino/backend_utils.cc index 4bfdc7e7aa9a7..cf7e9b2446bcb 100644 --- a/onnxruntime/core/providers/openvino/backend_utils.cc +++ b/onnxruntime/core/providers/openvino/backend_utils.cc @@ -47,11 +47,6 @@ struct static_cast_int64 { std::shared_ptr CreateCNNNetwork(const Provider_ModelProto& model_proto, const GlobalContext& global_context, const SubGraphContext& subgraph_context, std::map>& const_outputs_map) { -#if (defined OPENVINO_2020_2) || (defined OPENVINO_2020_3) - ORT_UNUSED_PARAMETER(const_outputs_map); -#endif - - std::istringstream model_stream{model_proto.SerializeAsString()}; std::shared_ptr ng_function; #ifndef NDEBUG @@ -60,6 +55,9 @@ CreateCNNNetwork(const Provider_ModelProto& model_proto, const GlobalContext& gl } #endif +#if (defined OPENVINO_2020_2) || (defined OPENVINO_2020_3) + ORT_UNUSED_PARAMETER(const_outputs_map); + std::istringstream model_stream{model_proto.SerializeAsString()}; try { ng_function = ngraph::onnx_import::import_onnx_model(model_stream); LOGS_DEFAULT(INFO) << "ONNX Import Done"; @@ -68,6 +66,20 @@ CreateCNNNetwork(const Provider_ModelProto& model_proto, const GlobalContext& gl } catch (...) { ORT_THROW(log_tag + "[OpenVINO-EP] Unknown exception while importing model to nGraph Func"); } +#else + InferenceEngine::CNNNetwork cnn_network; + const std::string model = model_proto.SerializeAsString(); + InferenceEngine::Blob::Ptr blob = {nullptr}; + try { + cnn_network = global_context.ie_core.ReadNetwork(model, blob); + LOGS_DEFAULT(INFO) << "Read network Done"; + } catch (const InferenceEngine::details::InferenceEngineException& e) { + ORT_THROW(log_tag + "[OpenVINO-EP] Exception while Reading network: " + std::string(e.what())); + } catch (...) { + ORT_THROW(log_tag + "[OpenVINO-EP] Unknown exception while Reading network"); + } + ng_function = cnn_network.getFunction(); +#endif if (global_context.device_type.find("GPU") != std::string::npos && subgraph_context.precision == InferenceEngine::Precision::FP16) { diff --git a/onnxruntime/core/providers/openvino/ov_versions/capability_2021_1.cc b/onnxruntime/core/providers/openvino/ov_versions/capability_2021_1.cc index d6459c4c3a79e..a31b4b4f9a062 100644 --- a/onnxruntime/core/providers/openvino/ov_versions/capability_2021_1.cc +++ b/onnxruntime/core/providers/openvino/ov_versions/capability_2021_1.cc @@ -272,16 +272,17 @@ static bool IsUnsupportedOpMode(const Node* node, const GraphViewer& graph_viewe return true; } } else if (optype == "Max" || optype == "Min" || optype == "Mean" || optype == "Sum") { - if (GetInputCount(node, initializers) == 1) + if (GetInputCount(node, initializers) == 1) { return true; - if (optype == "Max" || optype == "Min") { - for (size_t i = 0; i < node->InputDefs().size(); i++) { - auto dtype = node->InputDefs()[i]->TypeAsProto()->tensor_type().elem_type(); - if (dtype == ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT8 || - dtype == ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT16) - return true; - } + } + if (optype == "Max" || optype == "Min") { + for (size_t i = 0; i < node->InputDefs().size(); i++) { + auto dtype = node->InputDefs()[i]->TypeAsProto()->tensor_type().elem_type(); + if (dtype == ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT8 || + dtype == ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT16) + return true; } + } } else if (optype == "Clip") { //Only float 16, float and double data types are supported const bool data_is_float = node->InputDefs()[0]->Type()->find("float") != std::string::npos;