CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
[G-API] Fix bugs in GIEBackend #20918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[G-API] Fix bugs in GIEBackend #20918
Conversation
@@ -218,8 +218,6 @@ struct IEUnit { | |||
|
|||
cv::gapi::ie::detail::ParamDesc params; | |||
IE::CNNNetwork net; | |||
IE::InputsDataMap inputs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's better to removed them not get confused because they're relevant only in case LoadNetwork
|
||
IE::ExecutableNetwork this_network; | ||
cv::gimpl::ie::wrap::Plugin this_plugin; | ||
|
||
InferenceEngine::RemoteContext::Ptr rctx = nullptr; | ||
using PreProcMap = std::unordered_map<std::string, IE::PreProcessInfo>; | ||
mutable cv::util::optional<PreProcMap> preproc_map; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, relevant only for ImportNetwork
case, but should be stored anywhere after it's collected in outMeta
method.
static IE::PreProcessInfo configurePreProcInfo(const IE::InputInfo::CPtr& ii, | ||
const cv::GMetaArg& mm) { | ||
|
||
IE::PreProcessInfo info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case code won't go to none of these if
's, IE::PreProcessInfo
is empty, I believe that passing that to ExecutableNetwork::SetBlob
is OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't IE find preprocessing by name because info is empty?
Looks like code comment. API may be changed in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I meant for some inputs preprocessing isn't needed, in that case map will contain empty IE::PreProcessInfo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will be back bit later.
initDLDTDataPath(); | ||
|
||
cv::gapi::ie::detail::ParamDesc params; | ||
params.model_path= compileAgeGenderBlob(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
params.model_path= compileAgeGenderBlob(); | |
params.model_path = compileAgeGenderBlob(); |
static IE::PreProcessInfo configurePreProcInfo(const IE::InputInfo::CPtr& ii, | ||
const cv::GMetaArg& mm) { | ||
|
||
IE::PreProcessInfo info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't IE find preprocessing by name because info is empty?
Looks like code comment. API may be changed in the future.
Co-authored-by: Maxim Pashchenkov <maxim.pashchenkov@intel.com>
Co-authored-by: Maxim Pashchenkov <maxim.pashchenkov@intel.com>
const IE::DataPtr& ie_out = uu.outputs.at(out_name); | ||
const IE::SizeVector dims = ie_out->getTensorDesc().getDims(); | ||
const auto& desc = | ||
uu.params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Load |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly speaking looks awful, does anyone know how these different interfaces can be hidden? Should it be hidden at all?
} else if (params.kind == cv::gapi::ie::detail::ParamDesc::Kind::Import) { | ||
this_plugin = cv::gimpl::ie::wrap::getPlugin(params); | ||
this_plugin.SetConfig(params.config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config shouldn't be set to global IECore
object, moved this part to loadNetwork
and importNetwork
@@ -2239,6 +2267,141 @@ TEST(TestAgeGenderIE, InferWithBatch) | |||
normAssert(cv::gapi::ie::util::to_ocv(ie_gender), gapi_gender, "Test gender output"); | |||
} | |||
|
|||
|
|||
TEST(ImportNetwork, Infer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImportNetwork only tested for Infer
kernel for BGR
& NV12
format, testing other kernels on both of formats cause a huge code duplication I'd scope tests refactoring firstly, @dmatveev what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImportNetwork only tested for
Infer
kernel forBGR
&NV12
format, testing other kernels on both of formats cause a huge code duplication I'd scope tests refactoring firstly, @dmatveev what do you think?
Added 8 tests: [Infer
, InferROI
, InferList
, InferList2
] x [BGR
, NV12
]
Didn't test InferList2
on raw
inputs
|
||
IE::ExecutableNetwork this_network; | ||
cv::gimpl::ie::wrap::Plugin this_plugin; | ||
|
||
InferenceEngine::RemoteContext::Ptr rctx = nullptr; | ||
|
||
// FIXME: This map contains preprocessing information | ||
// for input layers in case ImportNetwork. Since this map is collected in | ||
// outMeta which is const, need to mark map as mutable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preproc_map
isn't mutable already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, thanks!
@@ -822,6 +818,24 @@ static void configureInputInfo(const IE::InputInfo::Ptr& ii, const cv::GMetaArg | |||
} | |||
} | |||
|
|||
static IE::PreProcessInfo configurePreProcInfo(const IE::InputInfo::CPtr& ii, | |||
const cv::GMetaArg& mm) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
for (auto &&it : ade::util::zip(ade::util::toRange(uu.params.input_names), | ||
ade::util::toRange(in_metas))) { | ||
const auto &input_name = std::get<0>(it); | ||
auto &&ii = uu.inputs.at(input_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This caused warning on Mac build
5a3268f
to
782abb2
Compare
static IE::Core core; | ||
return core; | ||
} | ||
|
||
IE::Core giewrap::getCore() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opencv/modules/dnn/src/op_inf_engine.cpp
Line 606 in 68d15fc
static InferenceEngine::Core* init_core = new InferenceEngine::Core(); // 'delete' is never called |
cv::Mat m_mat; | ||
Sync& m_sync; | ||
cv::Mat m_mat; | ||
std::shared_ptr<Sync> m_sync; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just handled the case where GMockMediaAdapter
live more than GMockSource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@alalek Could you have a look, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 , thanks!
* InferROI * InferList * InferList2
@@ -2239,6 +2282,582 @@ TEST(TestAgeGenderIE, InferWithBatch) | |||
normAssert(cv::gapi::ie::util::to_ocv(ie_gender), gapi_gender, "Test gender output"); | |||
} | |||
|
|||
TEST(ImportNetwork, Infer) | |||
{ | |||
const std::string device = "MYRIAD"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed task to avoid code duplication in tests
@alalek Could you merge it? |
@alalek it seems to be ready for merge |
…importNetwork [G-API] Fix bugs in GIEBackend * Remove inputs/outputs map from IEUnit * Add test * Add NV12 test * Reorganize setBlob function * Check that backend don't overwrite blob precision * Stop setting config to global IE::Core * Replace mutable to const_cast * Update modules/gapi/test/infer/gapi_infer_ie_test.cpp * Update modules/gapi/test/infer/gapi_infer_ie_test.cpp * Make blob parameter as const ref * Cosmetic fixes * Fix failed test on inferROI * Removed double ref for ii * Disable tests * Skip tests if device not available * Use Sync prim under shared_ptr to avoid issue on MAC * Apply WA for IE::Core * Apply WA for MAC build * Try to apply another WA * Not release IE::Core for apple * Put comment * Support PreprocInfo for * InferROI * InferList * InferList2 * Remove empty line * Fix alignment Co-authored-by: Maxim Pashchenkov <maxim.pashchenkov@intel.com>
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
Bugs overview
LoadNetwork
case.These maps: https://github.com/opencv/opencv/blob/master/modules/gapi/src/backends/ie/giebackend.cpp#L221-L222 are filled only in case LoadNetwork: https://github.com/opencv/opencv/blob/master/modules/gapi/src/backends/ie/giebackend.cpp#L241-L242, but are used by both of them:
https://github.com/opencv/opencv/blob/master/modules/gapi/src/backends/ie/giebackend.cpp#L953
cv::gapi::ie::Params::pluginConfig(IEConfig)
set config globally toIE::Core
, but should be set locally withinExecutableNetwork
: https://github.com/opencv/opencv/blob/master/modules/gapi/src/backends/ie/giebackend.cpp#L244-L245ImportNetwork
preprocessing should be passed asExecutableNetwork::SetBlob
argument, now preprocessing forNV12
color format is missed.Build configuration