[G-API] Pipeline modeling tool: Skip frames#21719
Conversation
| auto call_every_nth = | ||
| call_every_nth_opt.has_value() ? call_every_nth_opt.value() : 1; | ||
| if (call_every_nth <= 0) { | ||
| throw std::logic_error(node_name + " call_every_nth must be greater than zero"); |
There was a problem hiding this comment.
suggest to print value also
| auto output = | ||
| check_and_read<OutputDescr>(node_fn, "output", node_name); | ||
| builder.addDummy(node_name, time, output); | ||
| builder.addDummy(node_name, call_every_nth_u, time, output); |
There was a problem hiding this comment.
how's about making struct for call_every_nth_u and further possible params?
There was a problem hiding this comment.
Do you mean like this:
builder.addDummy(NodeParams{node_name, call_every_nth_u}, time, output);
There was a problem hiding this comment.
👍🏻 yes, something like that
| // G-API doesn't support dynamic number of inputs/outputs. | ||
| if (inputs.size() > 1u) { | ||
| throw std::logic_error( | ||
| "skip_frame_nth is supported only for single input subgraphs"); |
There was a problem hiding this comment.
printing of inputs.size() will help in troubleshooting
| call.run(subgr_inputs, subgr_outputs); | ||
| auto comp = cv::GComputation(cv::GProtoInputArgs{subgr_inputs}, | ||
| cv::GProtoOutputArgs{subgr_outputs}); | ||
| call = CallNode{call.name, |
There was a problem hiding this comment.
do we over-wrap existing call operation with call_every_nth != 1 by a new operation with call_every_nth == 1 which has a counter and the same comp?
If my understanding is correct than in this case do we just return the previous Mat without actual calculation? if yes then why it is called as "skip frames"? I thought that by skip frames it means receiving something empty frames of increasing next frame awaiting duration
There was a problem hiding this comment.
Agree, naming is confusing. This is about calling some nodes(kernels) on every n iterations. (not on every iteration)
There was a problem hiding this comment.
I see,
Then question - Does it affect final measurement is some sort of way? maybe it had better to print information about node invocation count also in final report?
There was a problem hiding this comment.
If node works not on every frame, it obviously improves performance.
maybe it had better to print information about node invocation count also in final report
Not sure that this is useful info, let's wait for the feedback firstly
…eline_modeling_tool-skip-frames-for-nodes
| state.reset(new SubGraphState{}); | ||
| state->cc = comp.compile(in, std::move(compile_args)); | ||
|
|
||
| GAPI_Assert(state->cc.outMetas().size() == 1u); |
There was a problem hiding this comment.
There is no sense to double check it since it was checked in outMeta
| auto output = | ||
| check_and_read<OutputDescr>(node_fn, "output", node_name); | ||
| builder.addDummy(node_name, time, output); | ||
| builder.addDummy(node_name, call_every_nth_u, time, output); |
There was a problem hiding this comment.
Do you mean like this:
builder.addDummy(NodeParams{node_name, call_every_nth_u}, time, output);
| call.run(subgr_inputs, subgr_outputs); | ||
| auto comp = cv::GComputation(cv::GProtoInputArgs{subgr_inputs}, | ||
| cv::GProtoOutputArgs{subgr_outputs}); | ||
| call = CallNode{call.name, |
There was a problem hiding this comment.
Agree, naming is confusing. This is about calling some nodes(kernels) on every n iterations. (not on every iteration)
| // G-API doesn't support dynamic number of inputs/outputs. | ||
| if (inputs.size() > 1u) { | ||
| throw std::logic_error( | ||
| "skip_frame_nth is supported only for single input subgraphs"); |
| auto call_every_nth = | ||
| call_every_nth_opt.has_value() ? call_every_nth_opt.value() : 1; | ||
| if (call_every_nth <= 0) { | ||
| throw std::logic_error(node_name + " call_every_nth must be greater than zero"); |
08d11b9 to
702cfb0
Compare
dmatveev
left a comment
There was a problem hiding this comment.
Have a little idea what happens here but hope the app is ok.
Please provide a meaningful description in the future, it will be mandatory for all our MRs.
| SubGraphState& state) { | ||
| // NB: Make a call on the first iteration and skip the furthers. | ||
| if (state.call_counter == 0) { | ||
| state.cc(in, state.last_result); |
There was a problem hiding this comment.
So there may be an extra copy, right? Since this internal GComputation has its own writeBack() inside.
There was a problem hiding this comment.
If fact, there is extra copy.
https://github.com/opencv/opencv/blob/4.x/modules/gapi/src/executor/gexecutor.cpp#L163
because adapter->data() == out_mat.data
There was a problem hiding this comment.
Sorry, there is NO extract copy
Co-authored-by: Dmitry Matveev <dmitry.matveev@intel.com>
|
@alalek Could you merge it, please? |
…ing_tool-skip-frames-for-nodes [G-API] Pipeline modeling tool: Skip frames * Add skip feature * Refactoring * Fix warning * Put more comments * Fix comments to review * Agregate common params into structure * Fix warning * Clean up & add test * Add assert * Fix warning on Mac * Update modules/gapi/samples/pipeline_modeling_tool.cpp Co-authored-by: Dmitry Matveev <dmitry.matveev@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.
Build configuration