[G-API]: Eliminates detail::ParamDesc mention from public tests#18913
[G-API]: Eliminates detail::ParamDesc mention from public tests#18913OrestChura wants to merge 7 commits intoopencv:masterfrom
Conversation
| ParamDesc(std::string model, std::string weights, std::string device, | ||
| std::vector<std::string> inputNames, std::vector<std::string> outputNames, | ||
| std::unordered_map<std::string, ConstInput> constInputs, | ||
| std::size_t numIn, std::size_t numOut, Kind kind_, bool isGen, IEConfig config_) |
There was a problem hiding this comment.
Use const reference as input parameters
There was a problem hiding this comment.
Of course. Thanks!
Fixed
There was a problem hiding this comment.
rolled back and added std::move in initializations to make less copies if rvalues are passed
There was a problem hiding this comment.
@OrestChura Nope, that won't work. All of those objects will be copied to the function's arguments. You should use const reference or universal reference (aka && + std::forward)
There was a problem hiding this comment.
On the one hand no needed implement both overloads (const& and &&)
On the other hand In case copy, ParamsDesc(const& T) make only one copy but ParamDesc(T t) make copy + move
I'm ok with both of them
There was a problem hiding this comment.
I'd prefer to leave it as is now as it has some advantages and, actually, no so important because it's not the public code
There was a problem hiding this comment.
because it's not the public code
Actually, it is a public header:
modules/gapi/include/opencv2/gapi/infer/ie.hpp
"copy + move" vs "const reference + copy"
The second one is preferable.
Copying in the first case is done on a caller side. Such copying significantly increases binary code size in cases of multiple use (default).
Copying after "const reference" is limited to 1 instance of binary code.
There was a problem hiding this comment.
I see! OK then, thanks. I've returned the const references already.
| bool is_generic; | ||
| IEConfig config; | ||
|
|
||
| ParamDesc(const std::string& model, const std::string& weights, const std::string& device, |
There was a problem hiding this comment.
Understood, but you make copy here
There was a problem hiding this comment.
fixed, pls check if OK
There was a problem hiding this comment.
returned to const references #18913 (comment)
|
|
||
| struct ROIList: public ::testing::Test { | ||
| cv::gapi::ie::detail::ParamDesc params; | ||
| std::string model_path = "", weights_path = "", device_id = ""; |
There was a problem hiding this comment.
Such kind of initialization isn't necessary, because std::string has default ctor
There was a problem hiding this comment.
Oh, OK, thanks! removed
|
@OrestChura @TolyaTalamanov Friendly reminder. |
Rebase is required. |
- replaces explicit ParamDesc objects declarations by brace-enclosed initializer lists - has to add constructors for ParamDesc
- remove initializations for std::string variables - reduce copying in ParamDesc constructors
42ceb67 to
7829bed
Compare
|
@TolyaTalamanov please look one more time as there are new tests from the recent PR which have required fixes |
7829bed to
cfb2ce9
Compare
smirnov-alexey
left a comment
There was a problem hiding this comment.
Please, fix copying
|
@alalek Let's merge this please |
- hardcoded key values replaced by IE::PluginConfigParams:: references
|
@alalek should I squash? |
alalek
left a comment
There was a problem hiding this comment.
should I squash?
Not required. There is no mess on GitHub's diff page.
dmatveev
left a comment
There was a problem hiding this comment.
I don't understand what part of what is eliminated, tbh..
There's more new lines than deleted lines, too.
| const std::vector<std::string>& inputNames, | ||
| const std::vector<std::string>& outputNames, | ||
| const std::unordered_map<std::string, ConstInput>& constInputs, | ||
| std::size_t numIn, std::size_t numOut, Kind kind_, bool isGen, | ||
| const IEConfig& config_) |
There was a problem hiding this comment.
Why do we need this constructor at all?
There was a problem hiding this comment.
I mean, the {}-thing should work?
There was a problem hiding this comment.
Overall - I would not expect any changes at the module API level when there is some test work happening.
There was a problem hiding this comment.
This constructor is needed exactly not to change API anywhere else.
I needed the other constructor for possibility to forward ParamDesc in functions via {model, weights, device} statement. But in Params<Net> here the full constructor is used, so I had to add the full constructor explicitly
| params.model_path, params.weights_path, params.device_id | ||
| }.cfgOutputLayers({ "age_conv3", "prob" }); | ||
| auto pp = cv::gapi::ie::Params<AgeGender> {model_path, weights_path, device_id | ||
| }.cfgOutputLayers({ "age_conv3", "prob" }); |
There was a problem hiding this comment.
Something strange happened to this formatting.
it is not supposed to look like this.
There was a problem hiding this comment.
I can format to the indentation like it was before in this snippet
| num_out(numOut), kind(kind_), is_generic(isGen), config(config_) {}; | ||
|
|
||
| ParamDesc(const std::string& model, const std::string& weights, const std::string& device) | ||
| : model_path(model), weights_path(weights), device_id(device) {}; |
There was a problem hiding this comment.
Uninitialized fields (static code scans will come here):
- num_in
- num_out
- kind
- is_generic
|
After a discussion, it is decided to leave |
|
Thanks Orest! |
This change:
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request