-
Notifications
You must be signed in to change notification settings - Fork 127
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
Added functionality to choose dml adapter by luid #1041
base: main
Are you sure you want to change the base?
Added functionality to choose dml adapter by luid #1041
Conversation
Thank you for this contribution. Can you please add a test/tests for the new functionality? |
This should be reviewed by the DML team. |
8ceb706
to
691d9e3
Compare
src/dml/dml_helpers.cpp
Outdated
ComPtr<IDXGIAdapter1> adapter; | ||
for (uint32_t adapter_index = 0; dxgi_factory->EnumAdapters1(adapter_index, &adapter) != DXGI_ERROR_NOT_FOUND; adapter_index++) { | ||
// We can't assume the ordering of hardware and software adapters, so keep looping. This path should only execute on Windows 10 | ||
// version 1709 or earlier; IDD (e.g. remote desktop) adapters do not exist when taking this code path. | ||
if (IsSoftwareAdapter(adapter.Get())) { | ||
continue; | ||
} | ||
|
||
// Make sure that we are able to create the device | ||
ComPtr<ID3D12Device> d3d12_device; | ||
THROW_IF_FAILED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&d3d12_device))); |
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.
This enumeration code is the same as the code below. I think It's better to have a single else
block, and to only have an if (device_luid)
when it's time to actually push it to the adapter_infos
vector.
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.
Thanks, I updated it
691d9e3
to
329214d
Compare
src/models/model.cpp
Outdated
if (name == "luid_high_part") { | ||
device_luid.HighPart = std::stol(value); | ||
contains_device_luid = true; | ||
} else if (name == "luid_low_part") { | ||
device_luid.LowPart = std::stol(value); | ||
contains_device_luid = true; | ||
} |
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.
What happens if the user only specifies the low or high part of the luid? Alternatively, can't we simply parse the entire LUID from a single string?
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.
If the user only specifies the low or high part of the luid, the program will crush. Yes, I can change it and specify luid by a single string, where high part and low part will be separated by ":" symbol
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.
Updated
329214d
to
0c9aef8
Compare
@@ -497,8 +514,8 @@ void Model::CreateSessionOptionsFromConfig(const Config::SessionOptions& config_ | |||
|
|||
// If no device gets set, default to CPU | |||
if (!p_device_) { | |||
assert(device_type_ == DeviceType::CPU); | |||
p_device_ = GetDeviceInterface(device_type_); | |||
assert(device_type_ == DeviceType::CPU || device_type_ == DeviceType::DML || device_type_ == DeviceType::WEBGPU); |
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.
This line throws an error when device_type_
is set to DML
. I believe both DML
and WEBGPU
should use the CPU
DeviceInterface
to avoid this issue.
Description: This PR adds functionality to allow users to specify a "DML" (DirectML) execution provider device adapter by providing the adapter's LUID (Locally Unique Identifier). Previously, the system would automatically select the most performant adapter by default. With this enhancement, users can now select a specific adapter by passing the luid_high_part and luid_low_part options, giving them greater control over device selection.
Key Changes:
Added support for selecting a DML execution provider device adapter using luid_high_part and luid_low_part.
Default behavior remains the same, choosing the most performant adapter unless these options are specified.
Motivation: This update provides more flexibility for users needing to target specific adapters, enhancing customizability in environments with multiple available adapters.
#1029