mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #24658 from smirnov-alexey:as/gapi_ov_get_model_layout
G-API: Get input model layout from the IR if possible in OV 2.0 backend #24658 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -774,14 +774,19 @@ public:
|
||||
if (explicit_in_model_layout) {
|
||||
input_info.model().set_layout(::ov::Layout(*explicit_in_model_layout));
|
||||
} else if (m_model->input(input_name).get_shape().size() == 4u) {
|
||||
// NB: Back compatibility with IR's without any layout information.
|
||||
// Note that default is only applicable for 4D inputs in order to
|
||||
// support auto resize for image use cases.
|
||||
GAPI_LOG_WARNING(NULL, "Failed to find layout for input layer \""
|
||||
<< input_name << "\" - NCHW is set by default");
|
||||
const std::string default_layout = "NCHW";
|
||||
input_info.model().set_layout(::ov::Layout(default_layout));
|
||||
m_input_model_layout.emplace(input_name, default_layout);
|
||||
const auto& input_layout = ::ov::layout::get_layout(m_model->input(input_name));
|
||||
if (!input_layout.empty()) {
|
||||
GAPI_LOG_INFO(NULL, "Model input layout " << input_name << " found: " << input_layout.to_string() << ".");
|
||||
} else {
|
||||
// NB: Back compatibility with IR's without any layout information.
|
||||
// Note that default is only applicable for 4D inputs in order to
|
||||
// support auto resize for image use cases.
|
||||
GAPI_LOG_WARNING(NULL, "Failed to find layout for input layer \""
|
||||
<< input_name << "\" - NCHW is set by default");
|
||||
const std::string default_layout = "NCHW";
|
||||
input_info.model().set_layout(::ov::Layout(default_layout));
|
||||
m_input_model_layout.emplace(input_name, default_layout);
|
||||
}
|
||||
}
|
||||
const auto explicit_in_tensor_layout = lookUp(m_input_tensor_layout, input_name);
|
||||
if (explicit_in_tensor_layout) {
|
||||
|
||||
Reference in New Issue
Block a user