-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[DML] Add support for AppendExecutionProvider_DML1 with C#. #22291
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay to me, but deferring to someone else (Dmitri maybe?) who has touched this file as I don't really know C# anymore.
uint /*(uint32_t)*/ version, | ||
out IntPtr /* const OrtMemoryInfo** */ provider_api); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally we require (although this was not enforced in the past) lines to be of 120 chars or less.
And, yes, we use default C# formating.
/// </summary> | ||
/// <param name="dmlDevice">A IDMLDevice reference</param> | ||
/// <param name="commandQueue">A ID3D12CommandQueue reference</param> | ||
public void AppendExecutionProvider_DML1(IntPtr dmlDevice, IntPtr commandQueue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, we do not expose native IntPtr handles via public API. The preferred way is to expose an object of DmlDevice that has a handle.
That object is likely to be IDisposable.
Then that object can expose an internal
property Handle that can be used for NativeApi.
The same probably goes for commandQueue.
Co-authored-by: Dwayne Robinson <[email protected]>
Description
Adds the ability to use the SessionOptionsAppendExecutionProvider_DML1 method with C#.
Motivation and Context
It was not possible to use the SessionOptionsAppendExecutionProvider_DML1 method with C# before. This PR adds adds the mapping of the DML EP, only for the SessionOptionsAppendExecutionProvider_DML1 method. The user of the library is still required to create the IDMLDevice and ID3D12CommandQueue manually, however that may be.
We validated that this works BY using CsWin32 to create projections of the native types and copying the logic from the ESRGAN super-resolution model sample, in particular, the SelectAdapter and CreateDmlDeviceAndCommandQueue methods from the helpers.cpp class.
A follow-up PR could make this process even simpler and provide this helper method, but it seemed a little bit too much for the basic support.