[G-API] Pipeline modeling tool - support local infer node config#22518
Conversation
|
@smirnov-alexey @dmatveev Hi folks! Could you have a look? |
| } else if (node_type == "Infer") { | ||
| auto infer_params = read<InferParams>(node_fn); | ||
| infer_params.config = config; | ||
| RETHROW_WITH_MSG_IF_FAILED( |
There was a problem hiding this comment.
Generally, macros are evil /=
There was a problem hiding this comment.
I'll remove this macro and leave just try-catch there
| infer_params.config = config; | ||
| RETHROW_WITH_MSG_IF_FAILED( | ||
| utils::intersectMapWith(infer_params.config, gconfig), | ||
| "Failed to combine global and local configs for Infer node: " |
There was a problem hiding this comment.
Why it could fail? How user could deal with it?
There was a problem hiding this comment.
If user provides global and local configs that have intersection app fails with: Met dublicated key which is not descriptive. It would be great to see something like: Failed to merge global & local configs for model <model.xml>, but utils::intersectMapWith knows nothing about modes & configs it just merges map's
| std::stringstream ss; \ | ||
| ss << msg << "\n caused by: " << e.what(); \ | ||
| throw std::logic_error(ss.str()); \ | ||
| } \ |
There was a problem hiding this comment.
What is the reason to do this? Maybe @sivanov-work have more to say here? :)
There was a problem hiding this comment.
Answered above
There was a problem hiding this comment.
Removed ugly macro
| if (it != target.end()) { | ||
| throw std::logic_error("Met already existing key: " + item.first); | ||
| } | ||
| target.insert(item); |
There was a problem hiding this comment.
In set theory, intersection is something different from this, isn't it?
Don't you just merge two maps into one with handling the "overwrites"?
There was a problem hiding this comment.
Yes, good point!
| for (auto&& item : second) { | ||
| auto it = target.find(item.first); | ||
| if (it != target.end()) { | ||
| throw std::logic_error("Met already existing key: " + item.first); |
There was a problem hiding this comment.
"Error: key X already exists in Y" is better IMO.
There was a problem hiding this comment.
Yes, but X & Y are nameless.
There was a problem hiding this comment.
X is the value of your item.first.
Y is the map you're merging into.
There was a problem hiding this comment.
This Y doesn't have a name. Done
* Rename intersectMapWith -> mergeMapWith * Remove macro * Add r-value ref
|
Is everybody OK to merge it? |
|
|
||
| template <typename K, typename V> | ||
| void mergeMapWith(std::map<K, V>& target, const std::map<K, V>& second) { | ||
| for (auto&& item : second) { |
There was a problem hiding this comment.
/build/precommit_linux64/4.x/opencv/modules/gapi/samples/pipeline_modeling_tool.cpp:196:5: error: invalid initialization of non-const reference of type 'cv::FileNode&' from an rvalue of type 'cv::FileNode
Reverted back
|
@alalek @asmorkalov Can it be merged? |
6a5f68c to
4521d66
Compare
|
|
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.
Overview
The motivation of this PR is the following:
configconfigin.ymlconfig file once is more convenient if it isn't supposed to be changed according user scenario.The logic is following:
Infernode locally via.ymlconfig file.localconfig might be combined withglobal(in case it's specified via--load_config) until they have key conflicts.