Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Extra error handling around EP cpu fallback

laurenspriem3b780547d4f2
diff --git a/mobile/apps/photos/rust/src/ml/onnx.rs b/mobile/apps/photos/rust/src/ml/onnx.rs
index d390693ba5..09c784b602 100644
--- a/mobile/apps/photos/rust/src/ml/onnx.rs
+++ b/mobile/apps/photos/rust/src/ml/onnx.rs
@@ -34,10 +34,15 @@ pub fn build_session(model_path: &str, policy: &ExecutionProviderPolicy) -> MlRe
providers.push(CPUExecutionProvider::default().build());
}
- if !providers.is_empty() {
- builder = builder.with_execution_providers(providers)?;
+ if providers.is_empty() {
+ return Err(MlError::InvalidRequest(
+ "no supported execution provider selected for this platform while CPU fallback is disabled"
+ .to_string(),
+ ));
}
+ builder = builder.with_execution_providers(providers)?;
+
let session = builder.commit_from_file(model_path)?;
Ok(session)
}