Skip to content

Commit

Permalink
Move hardware adapter check
Browse files Browse the repository at this point in the history
  • Loading branch information
nums11 committed Sep 19, 2023
1 parent 1ecd83c commit 86c9ec3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions onnxruntime/core/providers/dml/dml_provider_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,16 @@ bool IsHardwareAdapter(ComPtr<IDXCoreAdapter> adapter) {
}

bool IsGPU(ComPtr<IDXCoreAdapter> compute_adapter) {
// Only considering hardware adapters
if (!IsHardwareAdapter(compute_adapter))
return false;
return compute_adapter->IsAttributeSupported(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS);
}

bool IsNPU(ComPtr<IDXCoreAdapter> compute_adapter) {
// Only considering hardware adapters
if (!IsHardwareAdapter(compute_adapter))
return false;
return !(compute_adapter->IsAttributeSupported(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS));
}

Expand Down Expand Up @@ -304,10 +310,6 @@ API_IMPL_BEGIN
ORT_THROW_IF_FAILED(
d3D12CoreComputeAdapters->GetAdapter(i, candidateAdapter.GetAddressOf()));

// Only considering hardware adapters
if (!IsHardwareAdapter(candidateAdapter))
continue;

if (dev_filter == OrtDmlDeviceFilter::Gpu) // consider GPUs only
{

Check warning on line 314 in onnxruntime/core/providers/dml/dml_provider_factory.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/dml/dml_provider_factory.cc#L314

At least two spaces is best between code and comments [whitespace/comments] [2]
Raw output
onnxruntime/core/providers/dml/dml_provider_factory.cc:314:  At least two spaces is best between code and comments  [whitespace/comments] [2]
if (IsGPU(candidateAdapter)) {
Expand Down

0 comments on commit 86c9ec3

Please sign in to comment.