diff --git a/onnxruntime/core/providers/dml/dml_provider_factory.cc b/onnxruntime/core/providers/dml/dml_provider_factory.cc index c9ede6a9e53e1..46651a5d1c674 100644 --- a/onnxruntime/core/providers/dml/dml_provider_factory.cc +++ b/onnxruntime/core/providers/dml/dml_provider_factory.cc @@ -263,10 +263,16 @@ bool IsHardwareAdapter(ComPtr adapter) { } bool IsGPU(ComPtr compute_adapter) { + // Only considering hardware adapters + if (!IsHardwareAdapter(compute_adapter)) + return false; return compute_adapter->IsAttributeSupported(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS); } bool IsNPU(ComPtr compute_adapter) { + // Only considering hardware adapters + if (!IsHardwareAdapter(compute_adapter)) + return false; return !(compute_adapter->IsAttributeSupported(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS)); } @@ -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 { if (IsGPU(candidateAdapter)) {