Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/onnxruntime/core/framework/execution_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ class IExecutionProvider {
/**
Get the device id of current execution provider
*/
virtual int GetDeviceId() const { return default_device_.Id(); };
virtual int GetDeviceId() const { return default_device_.Id(); }

/**
* Get the OrtDevice the execution provider was registered with.
*/
const OrtDevice& GetDevice() const { return default_device_; }

/**
Get execution provider's configuration options.
Expand Down
12 changes: 7 additions & 5 deletions onnxruntime/core/session/inference_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1984,13 +1984,15 @@ static void ResolveMemoryPatternFlags(SessionState& session_state) {
// For now, this function only checks for invalid combination of DML EP with other EPs.
// TODO: extend this function to check for other invalid combinations of EPs.
common::Status InferenceSession::HasInvalidCombinationOfExecutionProviders() const {
// DML EP is only allowed with CPU EP
// DML EP is not allowed with other GPU or NPU EPs.
// historical reason for this is unknown. relaxing the limit that it must only be used with the CPU EP to support
// scenarios where alternative EPs are CPU based (e.g. openvino).
bool has_dml_ep = execution_providers_.Get(kDmlExecutionProvider) != nullptr;
if (has_dml_ep) {
const auto& ep_list = execution_providers_.GetIds();
for (const auto& ep : ep_list) {
if (ep == kDmlExecutionProvider || ep == kCpuExecutionProvider) continue;
return common::Status(common::ONNXRUNTIME, common::INVALID_ARGUMENT, "DML EP can be used with only CPU EP.");
for (const auto& ep : execution_providers_) {
if (ep->Type() != kDmlExecutionProvider && ep->GetDevice().Type() != OrtDevice::CPU) {
return common::Status(common::ONNXRUNTIME, common::INVALID_ARGUMENT, "DML EP can only be used with CPU EPs.");
}
}
}
return Status::OK();
Expand Down
Loading