π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move WebGPU support under ONNX
laurenspriem632f45276f35
diff --git a/rust/crates/photos/src/ml/indexing.rs b/rust/crates/photos/src/ml/indexing.rsindex 5ed433d338..ab05d712b0 100644--- a/rust/crates/photos/src/ml/indexing.rs+++ b/rust/crates/photos/src/ml/indexing.rs@@ -7,6 +7,7 @@ use crate::ml::{thumbnail::{FaceBox, generate_face_thumbnails},},model::{self, Model},+ onnx,pet::{run_pet_body_detection, run_pet_body_embedding, run_pet_face_alignment,run_pet_face_detection, run_pet_face_embedding,@@ -14,7 +15,6 @@ use crate::ml::{preprocess,runtime::{self, ModelPaths},types::{self, ClipResult, Dimensions, FaceResult, PetBodyResult, PetFaceResult},- webgpu,};use ente_image::decode::{decode_image_from_bytes, decode_image_from_path};@@ -62,7 +62,7 @@ pub struct RunClipTextResult {// Call before creating sessions; existing sessions keep their configuration.pub fn set_ml_execution_config(enable_webgpu: bool) {- webgpu::set_enabled(enable_webgpu);+ onnx::set_webgpu_enabled(enable_webgpu);}pub fn init_ml_runtime(model_paths: ModelPaths) {diff --git a/rust/crates/photos/src/ml/mod.rs b/rust/crates/photos/src/ml/mod.rsindex b3fd32e012..560687f2c7 100644--- a/rust/crates/photos/src/ml/mod.rs+++ b/rust/crates/photos/src/ml/mod.rs@@ -16,4 +16,3 @@ pub mod runtime;pub mod types;#[cfg(feature = "usearch")]pub mod vector_db;-mod webgpu;diff --git a/rust/crates/photos/src/ml/onnx/mod.rs b/rust/crates/photos/src/ml/onnx.rssimilarity index 99%rename from rust/crates/photos/src/ml/onnx/mod.rsrename to rust/crates/photos/src/ml/onnx.rsindex ee11a86f42..e4762c0dcc 100644--- a/rust/crates/photos/src/ml/onnx/mod.rs+++ b/rust/crates/photos/src/ml/onnx.rs@@ -3,12 +3,15 @@ use std::{fmt, path::Path};use crate::ml::error::{MlError, MlResult};use crate::ml::golden;-#[cfg(any(target_os = "android", target_os = "linux", target_os = "windows"))]-use crate::ml::webgpu;mod coreml_cache;mod providers;mod tensor;+mod webgpu;++pub(crate) fn set_webgpu_enabled(enabled: bool) {+ webgpu::set_enabled(enabled);+}pub(crate) use ort::session::Session as SessionHandle;pub(crate) use providers::ExecutionMode;diff --git a/rust/crates/photos/src/ml/onnx/providers.rs b/rust/crates/photos/src/ml/onnx/providers.rsindex a6974028f5..a5b8b50676 100644--- a/rust/crates/photos/src/ml/onnx/providers.rs+++ b/rust/crates/photos/src/ml/onnx/providers.rs@@ -19,7 +19,8 @@ use ort::ep::{#[cfg(target_os = "android")]use std::num::NonZeroUsize;-use crate::ml::error::MlResult;+#[cfg(any(target_os = "ios", target_os = "macos"))]+use super::coreml_cache;#[cfg(any(target_os = "android",target_os = "ios",@@ -27,12 +28,10 @@ use crate::ml::error::MlResult;target_os = "macos",target_os = "windows"))]-use crate::ml::golden;+use super::model_file_label;#[cfg(any(target_os = "android", target_os = "linux", target_os = "windows"))]-use crate::ml::webgpu;--#[cfg(any(target_os = "ios", target_os = "macos"))]-use super::coreml_cache;+use super::webgpu;+use crate::ml::error::MlResult;#[cfg(any(target_os = "android",target_os = "ios",@@ -40,7 +39,7 @@ use super::coreml_cache;target_os = "macos",target_os = "windows"))]-use super::model_file_label;+use crate::ml::golden;#[cfg(any(target_os = "ios", target_os = "macos"))]const ENABLE_PERSISTENT_COREML_CACHE: bool = true;diff --git a/rust/crates/photos/src/ml/webgpu.rs b/rust/crates/photos/src/ml/onnx/webgpu.rssimilarity index 100%rename from rust/crates/photos/src/ml/webgpu.rsrename to rust/crates/photos/src/ml/onnx/webgpu.rs