Disable loading of v7 reader for new IR versions (#12252)

* Disable loading of v7 reader for new IR versions

* Try to fix CI

* Fixed PDPD frontend

* Fixed error message creation
This commit is contained in:
Ilya Churaev authored and GitHub committed 2022-07-22 23:34:04 +04:00
1 parent 926a87e7eb
commit cb6ca7bb89
2 files changed
+40 -35

No files matched your search

+4
View File
@@ -272,6 +272,10 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
std::ifstream model_stream;
std::ifstream weights_stream;
std::istream* p_model_stream = paddle::variant_to_stream_ptr(variants[0], model_stream);
if (!variants[1].is<std::istream*>() && !variants[1].is<std::string>()) {
// If we use read model with a tensor as a second argument
return nullptr;
}
std::istream* p_weights_stream = paddle::variant_to_stream_ptr(variants[1], weights_stream);
if (p_model_stream && p_weights_stream) {
return std::make_shared<InputModel>(std::vector<std::istream*>{p_model_stream, p_weights_stream},
+36 -35
View File
@@ -464,22 +464,6 @@ CNNNetwork details::ReadNetwork(const std::string& modelPath,
const std::vector<IExtensionPtr>& exts,
const std::vector<ov::Extension::Ptr>& ov_exts,
bool newAPI) {
#ifdef ENABLE_IR_V7_READER
// IR v7 obsolete code
{
// Register readers if it is needed
registerReaders();
auto cnnnetwork = load_ir_v7_network(modelPath, binPath, exts);
OPENVINO_SUPPRESS_DEPRECATED_START
if (static_cast<ICNNNetwork::Ptr>(cnnnetwork) != nullptr) {
OPENVINO_ASSERT(!newAPI, "Cannot read IR v7 from OpenVINO 2.0 API");
return cnnnetwork;
}
OPENVINO_SUPPRESS_DEPRECATED_END
}
#endif // ENABLE_IR_V7_READER
// Fix unicode name
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::wstring model_path = ov::util::string_to_wstring(modelPath.c_str());
@@ -516,10 +500,27 @@ CNNNetwork details::ReadNetwork(const std::string& modelPath,
return convert_to_cnnnetwork(ngFunc, exts, newAPI);
}
#ifdef ENABLE_IR_V7_READER
// IR v7 obsolete code
{
// Register readers if it is needed
registerReaders();
auto cnnnetwork = load_ir_v7_network(modelPath, binPath, exts);
OPENVINO_SUPPRESS_DEPRECATED_START
if (static_cast<ICNNNetwork::Ptr>(cnnnetwork) != nullptr) {
OPENVINO_ASSERT(!newAPI, "Cannot read IR v7 from OpenVINO 2.0 API");
return cnnnetwork;
}
OPENVINO_SUPPRESS_DEPRECATED_END
}
#endif // ENABLE_IR_V7_READER
const auto fileExt = modelPath.substr(modelPath.find_last_of(".") + 1);
std::string FEs;
for (const auto& fe_name : manager.get_available_front_ends())
FEs += fe_name + " ";
IE_THROW(NetworkNotRead) << "Unable to read the model: " << modelPath
<< " Please check that model format: " << fileExt
<< " is supported and the model is correct."
@@ -535,25 +536,6 @@ CNNNetwork details::ReadNetwork(const std::string& model,
std::istringstream modelStringStream(model);
std::istream& modelStream = modelStringStream;
#ifdef ENABLE_IR_V7_READER
// IR v7 obsolete code
{
// Register readers if it is needed
registerReaders();
assertIfIRv7LikeModel(modelStream);
for (auto it = readers.begin(); it != readers.end(); it++) {
auto reader = it->second;
if (reader->supportModel(modelStream)) {
OPENVINO_ASSERT(!newAPI, "Cannot read IR v7 from OpenVINO 2.0 API");
if (weights)
return reader->read(modelStream, weights, exts);
return reader->read(modelStream, exts);
}
}
}
#endif // ENABLE_IR_V7_READER
// Try to load with FrontEndManager
auto& manager = get_frontend_manager();
ov::frontend::FrontEnd::Ptr FE;
@@ -579,6 +561,25 @@ CNNNetwork details::ReadNetwork(const std::string& model,
return convert_to_cnnnetwork(ngFunc, exts, newAPI, frontendMode);
}
#ifdef ENABLE_IR_V7_READER
// IR v7 obsolete code
{
// Register readers if it is needed
registerReaders();
assertIfIRv7LikeModel(modelStream);
for (auto it = readers.begin(); it != readers.end(); it++) {
auto reader = it->second;
if (reader->supportModel(modelStream)) {
OPENVINO_ASSERT(!newAPI, "Cannot read IR v7 from OpenVINO 2.0 API");
if (weights)
return reader->read(modelStream, weights, exts);
return reader->read(modelStream, exts);
}
}
}
#endif // ENABLE_IR_V7_READER
IE_THROW(NetworkNotRead)
<< "Unable to read the model. Please check if the model format is supported and model is correct.";
}