Implement async version for InferList & Infer2#19709
Conversation
|
@AsyaPronina @rgarnov @smirnov-alexey Have a look, please |
|
@AsyaPronina @rgarnov @smirnov-alexey Could you have a look, please ? |
smirnov-alexey
left a comment
There was a problem hiding this comment.
Overall, looks good
|
@dmatveev Could you have a look ? |
| std::shared_ptr<IECallContext> ctx; | ||
| std::vector<std::vector<int>> cached_dims; | ||
| }; | ||
| std::shared_ptr<Priv> m_priv; |
There was a problem hiding this comment.
Do we really need this if class is only in implementation part?
There was a problem hiding this comment.
Yes, because it contains atomic which doesn't have copy ctor
There was a problem hiding this comment.
Another reason to implement it such way is: object should be shared between async requests
| if (finished == size) { | ||
| for (auto i : ade::util::iota(ctx->uu.params.num_out)) { | ||
| auto output = ctx->output(i); | ||
| ctx->out.meta(output, cv::GRunArg::Meta{}); |
There was a problem hiding this comment.
I am not sure that we can somehow retrieve input meta here from input args, but is it okay to post empty meta?
There was a problem hiding this comment.
Yes, it isn't ok and well-known problem, but this PR about: "Support async execution for InferList and Infer2".
But anyway I can fix it in this PR.
There was a problem hiding this comment.
We shouldn't introduce new problems now if they are well known, so please address it here too.
There was a problem hiding this comment.
Agree, fixed
| for (auto i : ade::util::iota(ctx->uu.params.num_out)) { | ||
| auto output = ctx->output(i); | ||
| ctx->out.meta(output, cv::GRunArg::Meta{}); | ||
| ctx->out.post(std::move(output)); |
There was a problem hiding this comment.
this code is duplicated, may be we can retrieve it to some common method/function?
There was a problem hiding this comment.
Yea, I think it can implemented as a separate function to reuse code
| cached_dims[i] = toCV(ie_out->getTensorDesc().getDims()); | ||
| // FIXME: Isn't this should be done automatically | ||
| // by some resetInternalData(), etc? (Probably at the GExecutor level) | ||
| ctx->outVecR<cv::Mat>(i).clear(); |
There was a problem hiding this comment.
this code is also duplicated, how much does it cost to retrieve it to some common place?
Do we have some obstacles and this work seems extra?
There was a problem hiding this comment.
This isn't my code, so I wouldn't touch at least in this PR, moreover it already has a comment about moving this to common place
| if (finished == size) { | ||
| for (auto i : ade::util::iota(ctx->uu.params.num_out)) { | ||
| auto output = ctx->output(i); | ||
| ctx->out.meta(output, cv::GRunArg::Meta{}); |
There was a problem hiding this comment.
We shouldn't introduce new problems now if they are well known, so please address it here too.
b9b6592 to
f6c0fc1
Compare
| // FIXME: Isn't this should be done automatically | ||
| // by some resetInternalData(), etc? (Probably at the GExecutor level) | ||
| auto& out_vec = ctx->outVecR<cv::Mat>(i); | ||
| out_vec.clear(); |
There was a problem hiding this comment.
In fact it isn't necessary because we reset it by calling Mat::create in callback, but I think call clear explicitly is clearer
| IE::Blob::Ptr out_blob = req.GetBlob(ctx->uu.params.output_names[i]); | ||
| GAPI_Assert(out_blob); | ||
|
|
||
| cv::Mat out_mat(cached_dims[i], toCV(out_blob->getTensorDesc().getPrecision())); |
There was a problem hiding this comment.
It seems you don't need this mat here?
There was a problem hiding this comment.
Damn, silly mistake, done
f6c0fc1 to
1ee49d8
Compare
|
@alalek Can it be merged ? |
…t-infer2 G-API: Implement async version for InferList & Infer2 * Implement async version for InferList & Infer2 * Fix warning * Fix bug with roi ordering * Post input meta instead of empty * Fix comments to review
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
This PR brings functionality to run
InferListandInfer2asynchronously.Build configuration