Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions onnxruntime/core/providers/openvino/backend_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ struct static_cast_int64 {

std::shared_ptr<InferenceEngine::CNNNetwork>
CreateCNNNetwork(const Provider_ModelProto& model_proto, const GlobalContext& global_context, const SubGraphContext& subgraph_context, std::map<std::string, std::shared_ptr<ngraph::Node>>& 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<ngraph::Function> ng_function;

#ifndef NDEBUG
Expand All @@ -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";
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down