Document generation for operator kernels, enable internal overload of DML EP to initialize on software-only devices (#13428)

### Description
The documentation pipeline does not require an actual GPU, and running
on GPU-capable agents costs more. So to enable running on CPU-only
devices and to potentially consolidate future pipelines, and since the
tests are not actually executed on this device anyway (it just needs to
initialize the EP for the sake of operator kernel enumeration), add an
initialization flag to skip the software device check - this is only an
internal overload not exposed in the public API. See
https://github.com/microsoft/onnxruntime/pull/13308.

### Motivation and Context
- *If it fixes an open issue, please link to the issue here.* NA
This commit is contained in:
Dwayne Robinson 2022-10-25 11:14:43 -07:00 committed by GitHub
parent d80212d42c
commit 0201cd75e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View file

@ -105,6 +105,10 @@ bool IsSoftwareAdapter(IDXGIAdapter1* adapter) {
}
std::shared_ptr<IExecutionProviderFactory> DMLProviderFactoryCreator::Create(int device_id) {
return Create(device_id, /*skip_software_device_check*/ false);
}
std::shared_ptr<IExecutionProviderFactory> DMLProviderFactoryCreator::Create(int device_id, bool skip_software_device_check) {
#ifdef _GAMING_XBOX
ComPtr<ID3D12Device> d3d12_device;
D3D12XBOX_CREATE_DEVICE_PARAMETERS params = {};
@ -120,8 +124,13 @@ std::shared_ptr<IExecutionProviderFactory> DMLProviderFactoryCreator::Create(int
ComPtr<IDXGIAdapter1> 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<ID3D12Device> d3d12_device;
ORT_THROW_IF_FAILED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_GRAPHICS_PPV_ARGS(d3d12_device.ReleaseAndGetAddressOf())));

View file

@ -10,5 +10,6 @@
namespace onnxruntime {
struct DMLProviderFactoryCreator {
static std::shared_ptr<IExecutionProviderFactory> Create(int device_id);
static std::shared_ptr<IExecutionProviderFactory> Create(int device_id, bool skip_software_device_check);
};
} // namespace onnxruntime

View file

@ -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),