diff --git a/onnxruntime/core/providers/dml/dml_provider_factory.cc b/onnxruntime/core/providers/dml/dml_provider_factory.cc index 8c8bb39f97..c8891cb214 100644 --- a/onnxruntime/core/providers/dml/dml_provider_factory.cc +++ b/onnxruntime/core/providers/dml/dml_provider_factory.cc @@ -105,6 +105,10 @@ bool IsSoftwareAdapter(IDXGIAdapter1* adapter) { } std::shared_ptr DMLProviderFactoryCreator::Create(int device_id) { + return Create(device_id, /*skip_software_device_check*/ false); +} + +std::shared_ptr DMLProviderFactoryCreator::Create(int device_id, bool skip_software_device_check) { #ifdef _GAMING_XBOX ComPtr d3d12_device; D3D12XBOX_CREATE_DEVICE_PARAMETERS params = {}; @@ -120,8 +124,13 @@ std::shared_ptr DMLProviderFactoryCreator::Create(int ComPtr adapter; ORT_THROW_IF_FAILED(dxgi_factory->EnumAdapters1(device_id, &adapter)); - // Disallow using DML with the software adapter (Microsoft Basic Display Adapter) because CPU evaluations are much faster - ORT_THROW_HR_IF(E_INVALIDARG, IsSoftwareAdapter(adapter.Get())); + // Disallow using DML with the software adapter (Microsoft Basic Display Adapter) because CPU evaluations are much + // faster. Some scenarios though call for EP initialization without this check (as execution will not actually occur + // anyway) such as operation kernel registry enumeration for documentation purposes. + if (!skip_software_device_check) + { + ORT_THROW_HR_IF(E_INVALIDARG, IsSoftwareAdapter(adapter.Get())); + } ComPtr d3d12_device; ORT_THROW_IF_FAILED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_GRAPHICS_PPV_ARGS(d3d12_device.ReleaseAndGetAddressOf()))); diff --git a/onnxruntime/core/providers/dml/dml_provider_factory_creator.h b/onnxruntime/core/providers/dml/dml_provider_factory_creator.h index 944a57cc06..3c3f04561d 100644 --- a/onnxruntime/core/providers/dml/dml_provider_factory_creator.h +++ b/onnxruntime/core/providers/dml/dml_provider_factory_creator.h @@ -10,5 +10,6 @@ namespace onnxruntime { struct DMLProviderFactoryCreator { static std::shared_ptr Create(int device_id); + static std::shared_ptr Create(int device_id, bool skip_software_device_check); }; } // namespace onnxruntime diff --git a/onnxruntime/python/onnxruntime_pybind_schema.cc b/onnxruntime/python/onnxruntime_pybind_schema.cc index 15e26c7986..f594b5712a 100644 --- a/onnxruntime/python/onnxruntime_pybind_schema.cc +++ b/onnxruntime/python/onnxruntime_pybind_schema.cc @@ -62,7 +62,7 @@ void addGlobalSchemaFunctions(pybind11::module& m) { onnxruntime::ArmNNProviderFactoryCreator::Create(0), #endif #ifdef USE_DML - onnxruntime::DMLProviderFactoryCreator::Create(0), + onnxruntime::DMLProviderFactoryCreator::Create(0, /*skip_software_device_check*/ true), #endif #ifdef USE_NNAPI onnxruntime::NnapiProviderFactoryCreator::Create(0),