Skip to content

G-API: oneVPL DX11 inference#21232

Merged
alalek merged 14 commits intoopencv:4.xfrom
sivanov-work:vpl_gpu_remote_infer
Jan 24, 2022
Merged

G-API: oneVPL DX11 inference#21232
alalek merged 14 commits intoopencv:4.xfrom
sivanov-work:vpl_gpu_remote_infer

Conversation

@sivanov-work
Copy link
Copy Markdown
Contributor

@sivanov-work sivanov-work commented Dec 10, 2021

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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to 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

Build Configuration

force_builders=XCustom,Custom Win,Custom Mac
build_gapi_standalone:Linux x64=ade-0.1.1f
build_gapi_standalone:Win64=ade-0.1.1f
build_gapi_standalone:Mac=ade-0.1.1f
build_gapi_standalone:Linux x64 Debug=ade-0.1.1f

Xbuild_image:Custom=centos:7
Xbuildworker:Custom=linux-1
build_gapi_standalone:Custom=ade-0.1.1f

build_image:Custom=ubuntu-openvino-2021.3.0:20.04
Xbuild_image:Custom Win=openvino-2021.2.0
build_image:Custom Mac=openvino-2021.2.0

test_modules:Custom=gapi,python2,python3,java
test_modules:Custom Win=gapi,python2,python3,java
test_modules:Custom Mac=gapi,python2,python3,java

buildworker:Custom=linux-1
test_opencl:Custom=OFF
test_bigdata:Custom=1
test_filter:Custom=*

build_image:Custom Win=gapi-onevpl-2021.6.0
buildworker:Custom Win=windows-3
build_contrib:Custom Win=OFF

@sivanov-work sivanov-work marked this pull request as ready for review December 15, 2021 09:38
@sivanov-work
Copy link
Copy Markdown
Contributor Author

one more commit is expected to fix CustomMac CI in a way to fix comparison between InferenceEngines types

@sivanov-work sivanov-work changed the title G-API: oneVPL DX11 inference (WIP) G-API: oneVPL DX11 inference Dec 15, 2021
@@ -510,15 +510,51 @@ inline IE::Blob::Ptr extractRemoteBlob(IECallContext& ctx, std::size_t i) {
using ParamType = std::pair<InferenceEngine::TensorDesc,
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.

Not for this changes but:
auto ie_core = cv::gimpl::ie::wrap::getCore(); - Is unused variable?

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.

you right, it seems is unused

if (ctx.uu.params.device_id.find("GPU") != std::string::npos) {
GAPI_LOG_DEBUG(nullptr, "Extract remote blob for GPU DX11 device_id: " <<
ctx.uu.params.device_id);
// despite of layout, blob dimensions always follow in N,C,H,W order
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.

Will only 4D blob be supported?

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.

it depends from openvino and code taken from openvino code make_shared_nv12_blob

// TODO NV12 surface supported only
if (static_cast<InferenceEngine::ColorFormat>(frame_blob_params->second["COLOR_FORMAT"]) ==
InferenceEngine::ColorFormat::NV12) {
InferenceEngine::Blob::Ptr y_blob =
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.

Can be used InferenceEngine::NV12Blob for this case?

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.

it has huge class hierarchy, but actually final blob must be one of descendant of ClBlob which represents remote GPU memory. Maybe NV12Blob is present in class inheritance in the middle chain, i'm not sure

if (static_cast<InferenceEngine::ColorFormat>(frame_blob_params->second["COLOR_FORMAT"]) ==
InferenceEngine::ColorFormat::NV12) {
InferenceEngine::Blob::Ptr y_blob =
std::dynamic_pointer_cast<InferenceEngine::Blob>(
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.

Can this be done with some make_..._blob functions? For interest.

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.

yes it is: 524 - 550 lines related to make_shared_nv12_blob API function and to declare that function we need to include specific OV include file with this make* API but this header file has a required dependency from OpenCL -HPP package which is not a part of openCV and should be not according to license type. So all make_* functions from OV simply unwrapped from its definition and copied here

*(ctx->uu.params.input_names.begin()),
IE::make_shared_blob(this_blob, toIE(this_roi)),
*ctx);
setROIBlob(req,
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 think, the function should be used for InferList and InferList2.
Can GPU ROI support appear in future?

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.

Do you mean - place such changes SetBlob -> SetROIBlob in other place? could you point me out, please?

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.

make_shared_blob for ROIs + SetBlob in InferList and InferList2. Is it necessary align this with SetRoiBlob? Now it is called in one place.

IE::Blob::Ptr roi_blob = IE::make_shared_blob(this_blob, toIE(rc));

this_blob = IE::make_shared_blob(blob_0, toIE(vec[list_idx]));

const cv::Rect &roi,
const IECallContext& ctx) {
if (ctx.uu.params.device_id.find("GPU") != std::string::npos) {
GAPI_LOG_DEBUG(nullptr, "Skip ROI blob creation for device_id: " <<
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.

This can confuse. M b it should be assert.

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.

definitely no: GPU blob doesn't support ROI but need to continue with SeBlob further
Let's apply limitation that ROI for GPU (right before OpenVINO 2.0 adaptation) must be done on G-API / GSource side manually

Copy link
Copy Markdown
Contributor

@mpashchenkov mpashchenkov left a comment

Choose a reason for hiding this comment

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

Some unanswered questions.

static_cast<uint64_t>(value), false);
}


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.

Extra empty line.

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.

fixed

@dmatveev dmatveev self-assigned this Jan 20, 2022
@dmatveev dmatveev added this to the category: g-api milestone Jan 20, 2022
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.

Approved with comments

" For exploring list of supported transformations please find out "
" vpp_* related stuff in"
" gapi/include/opencv2/gapi/streaming/onevpl/cfg_params.hpp\n"
" Pay attention that to obtain expected result In this case VPP "
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.

no \n here

Comment on lines +335 to +336
" Please consider param \"source_preproc_enable=1\" and specify "
" appropriated media frame transformation using oneVPL::VPP primitives"
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.

no \n here as well

Comment on lines +338 to +339
" For exploring list of supported transformations please find out "
" vpp_* related stuff in"
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.

wow here too

Comment on lines 513 to 521
ParamType* frame_blob_params = cv::util::any_cast<ParamType>(&any_blob_params);
if (frame_blob_params == nullptr) {
GAPI_Assert(false && "Incorrect type of blobParams: "
"expected std::pair<InferenceEngine::TensorDesc,"
"InferenceEngine::ParamMap>");
}
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.

so there should be bad_any_cast already so no need to use *

return ctx.uu.rctx->CreateBlob(blob_params->first,
blob_params->second);
if (ctx.uu.params.device_id.find("GPU") != std::string::npos) {
GAPI_LOG_DEBUG(nullptr, "Extract remote blob for GPU DX11 device_id: " <<
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 don't see the whole context but happens on Linux? GPU is perfectly valid there, but there's no DX11.

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.

no MediaFrame Adapter for it - DX11 only
There is a check with assert whilst we create Source that available device type

Copy link
Copy Markdown
Contributor

@OrestChura OrestChura left a comment

Choose a reason for hiding this comment

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

Some remaining comments can be answered and addressed in the next PR

@sivanov-work
Copy link
Copy Markdown
Contributor Author

it seems before merge need to rebase with latter nv12 changes in giebackend

@alalek
Copy link
Copy Markdown
Member

alalek commented Jan 20, 2022

dmatveev added this to the category: g-api milestone 6 hours ago

WTF???
Again, No new milestones please.

@sivanov-work
Copy link
Copy Markdown
Contributor Author

@alalek Could you merge it please? all un-addressed comments would by applied in the next PR #21363
with some little refactoring

@alalek alalek merged commit 266835c into opencv:4.x Jan 24, 2022
@alalek alalek mentioned this pull request Feb 22, 2022
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
G-API: oneVPL DX11 inference

* Draft GPU infer

* Fix incorrect subresource_id for array of textures

* Fix for TheOneSurface in different Frames

* Turn on VPP param configuration

* Add cropIn params

* Remove infer sync sample

* Remove comments

* Remove DX11AllocResource extra init

* Add condition for NV12 processing in giebackend

* Add VPP frames pool param configurable

* -M Remove extra WARN & INFOs, Fix custom MAC

* Remove global vars from example, Fix some comments, Disable blobParam due to OV issue

* Conflict resolving

* Revert back pointer cast for cv::any
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.

5 participants