Skip to content

[G-API] Pipeline modeling tool: Support num_iters criteria#22596

Merged
asmorkalov merged 5 commits intoopencv:4.xfrom
TolyaTalamanov:at/add-num-iter
Oct 7, 2022
Merged

[G-API] Pipeline modeling tool: Support num_iters criteria#22596
asmorkalov merged 5 commits intoopencv:4.xfrom
TolyaTalamanov:at/add-num-iter

Conversation

@TolyaTalamanov
Copy link
Copy Markdown
Contributor

@TolyaTalamanov TolyaTalamanov commented Oct 4, 2022

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Motiviation

Let's image use case where execution should last: 50ms

0ms       10ms      20ms      30ms        40ms       50ms
 |---------|---------|----------|----------|----------|

and one pipeline iterations takes 15ms.

In that case the picture will be:

       0 frame          1 frame       2 frame         3 frame
 |----------------|---------------|---------------|---------------|

0ms       10ms      20ms      30ms        40ms         50ms       60ms
 |**********|**********|**********|**********|**********|**********|
 
 FPS = 4 frames * 1000 / 60ms = 66.6 FPS 

But if user enabled --drop_frames the picture would be different:

       0 frame               1 frame              2 frame
 |----------------|    |---------------|      |---------------|

0ms       10ms        20ms      30ms        40ms         50ms  55ms
 |**********|*****-----|**********|*****------|**********|*****|
 
 FPS = 3 frames * 1000 / 55ms = 54.54 FPS 

So --drop_frames could significantly affect FPS, because number of iterations depends on this flag.
But what if user want to run certain number of iteration but at the same time schedule pipelines with --drop_frames mode?

Implementation

Now every Pipeline could have local num_iters property. The logic is following:

  • num_iters is local property for Pipeline. (no global num_iters)
  • if num_iters is set then it takes priority over work_time.
  • work_time is still global (no local work_time per Pipeline), but now is not necessary to be specified.
  • If Pipeline doesn't have num_iters property and global work_time isn't specified then throw error.

check_and_read<double>(fs, "work_time", "Config");
if (work_time_ms < 0) {
throw std::logic_error("work_time must be positive");
auto opt_work_time_ms = readOpt<double>(fs["work_time"]);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes will affect python tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return ss.str();
}

class StopCriteria {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably over design.
On the other hand what if another stop criteria will be needed (e.g N iters, but no more than Xms).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it is Criterion, not Criteria (plural form)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@asmorkalov asmorkalov requested a review from dmatveev October 4, 2022 11:15
@asmorkalov asmorkalov added this to the 4.7.0 milestone Oct 4, 2022
Pipelines:
PL1:\" """
PL1:
queue_capacity: 1\" """
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise PL1 not treated as Map and test gets failed

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@smirnov-alexey @dmatveev Could you have a look, please?

Copy link
Copy Markdown
Contributor

@dmatveev dmatveev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@asmorkalov Can it be merged?

@asmorkalov asmorkalov merged commit 5389d9e into opencv:4.x Oct 7, 2022
@alalek alalek mentioned this pull request Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants