Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G-API: Advanced device selection for ONNX DirectML Execution Provider #24060

Conversation

TolyaTalamanov
Copy link
Contributor

@TolyaTalamanov TolyaTalamanov commented Jul 26, 2023

Overview

Extend cv::gapi::onnx::ep::DirectML to accept adapter name as ctor parameter in order to select execution device by name.
E.g:

pp.cfgAddExecutionProvider(cv::gapi::onnx::ep::DirectML("Intel Graphics"));

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

@TolyaTalamanov TolyaTalamanov force-pushed the at/advanced-device-selection-onnxrt-directml branch from 954113d to 0e60ecc Compare July 26, 2023 13:38
modules/gapi/src/backends/onnx/dml_ep.cpp Outdated Show resolved Hide resolved
modules/gapi/src/backends/onnx/dml_ep.cpp Outdated Show resolved Hide resolved
#ifdef HAVE_DXCORE

// FIXME: Fix warning
#define WINVER 0x0A00
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But DXCore minimum required version is Windows 10:

Taken from system header: <dxcore.h>
image

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I propose to set WINVER globally in CMake.
  2. Cmake should print this during configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modules/gapi/src/backends/onnx/dml_ep.cpp Outdated Show resolved Hide resolved
@@ -369,6 +369,8 @@ if(HAVE_ONNX)
ocv_target_compile_definitions(${the_module} PRIVATE HAVE_ONNX=1)
if(HAVE_ONNX_DML)
ocv_target_compile_definitions(${the_module} PRIVATE HAVE_ONNX_DML=1)
# FIXME: It shouldn't be here...
ocv_target_compile_definitions(${the_module} PRIVATE HAVE_DXCORE=1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@opencv-alalek Could you advice how dxcore, d3d12 and directml can be detected by opencv?
Should we use the similar approach as there:
https://github.com/opencv/opencv/blob/4.x/cmake/OpenCVDetectDirectX.cmake ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we need to have something like OpenCVDetectDirectML.cmake

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@dmatveev dmatveev self-assigned this Jul 26, 2023
Copy link
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.

+1 to all open self-questions regarding managing the DX components and Windows version properly...

Copy link
Contributor

@smirnov-alexey smirnov-alexey left a comment

Choose a reason for hiding this comment

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

Overall looks OK but you need to resolve DXCORE and Windows version dependencies

@smirnov-alexey
Copy link
Contributor

@TolyaTalamanov also, can we add some tests or a sample on that feature?

@asmorkalov
Copy link
Contributor

@TolyaTalamanov @dmatveev Friendly reminder.

1 similar comment
@asmorkalov
Copy link
Contributor

@TolyaTalamanov @dmatveev Friendly reminder.

@TolyaTalamanov
Copy link
Contributor Author

@opencv-alalek @asmorkalov Hi folks! Could you have a look at this one more time, please?

@TolyaTalamanov
Copy link
Contributor Author

Hi @asmorkalov can we proceed with merge here?

@TolyaTalamanov TolyaTalamanov added this to the 4.9.0 milestone Nov 14, 2023
@TolyaTalamanov
Copy link
Contributor Author

@asmorkalov Hi! Let me know if there is anything else left

Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

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

👍

@asmorkalov asmorkalov merged commit 0e151e3 into opencv:4.x Nov 16, 2023
26 checks passed
@dmatveev
Copy link
Contributor

Cool - thanks @asmorkalov !

IskXCr pushed a commit to Haosonn/opencv that referenced this pull request Dec 20, 2023
…e-selection-onnxrt-directml

G-API: Advanced device selection for ONNX DirectML Execution Provider opencv#24060

### Overview
Extend `cv::gapi::onnx::ep::DirectML` to accept `adapter name` as `ctor` parameter in order to select execution device by `name`.
E.g:
```
pp.cfgAddExecutionProvider(cv::gapi::onnx::ep::DirectML("Intel Graphics"));
```

### 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
thewoz pushed a commit to thewoz/opencv that referenced this pull request Jan 4, 2024
…e-selection-onnxrt-directml

G-API: Advanced device selection for ONNX DirectML Execution Provider opencv#24060

### Overview
Extend `cv::gapi::onnx::ep::DirectML` to accept `adapter name` as `ctor` parameter in order to select execution device by `name`.
E.g:
```
pp.cfgAddExecutionProvider(cv::gapi::onnx::ep::DirectML("Intel Graphics"));
```

### 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
@asmorkalov asmorkalov mentioned this pull request Jan 19, 2024
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.

None yet

5 participants