Skip to content

Commit

Permalink
feat: allowed to apply multiple execution providers (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
DCjanus authored Aug 20, 2023
1 parent c0831c7 commit 561870a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/execution_providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ impl ExecutionProvider {

#[tracing::instrument(skip_all)]
pub(crate) fn apply_execution_providers(options: *mut sys::OrtSessionOptions, execution_providers: impl AsRef<[ExecutionProvider]>) {
let mut fallback_to_cpu = true;
for ex in execution_providers.as_ref() {
if let Err(e) = ex.apply(options) {
if let &OrtError::ExecutionProviderNotRegistered(_) = &e {
Expand All @@ -724,8 +725,10 @@ pub(crate) fn apply_execution_providers(options: *mut sys::OrtSessionOptions, ex
}
} else {
tracing::info!("Successfully registered `{}`", ex.as_str());
return;
fallback_to_cpu = false;
}
}
tracing::warn!("No execution providers registered successfully. Falling back to CPU.");
if fallback_to_cpu {
tracing::warn!("No execution providers registered successfully. Falling back to CPU.");
}
}

0 comments on commit 561870a

Please sign in to comment.