Parcourir la source

[mobile][photos] Reduce GC events when loading models (#1223)

## Description

When using `readAsBytes()`, noticed a lot of `concurrentMark` GC event
in timeline when using the performance profiler dev tool, which were
potentially causing longer build and raster time for frames.
Vishnu Mohandas il y a 1 an
Parent
commit
be62ea1459

+ 3 - 2
mobile/lib/services/machine_learning/semantic_search/frameworks/onnx/onnx_image_encoder.dart

@@ -15,9 +15,10 @@ class OnnxImageEncoder {
       ..setIntraOpNumThreads(1)
       ..setSessionGraphOptimizationLevel(GraphOptimizationLevel.ortEnableAll);
     try {
-      final bytes = await File(args["imageModelPath"]).readAsBytes();
-      final session = OrtSession.fromBuffer(bytes, sessionOptions);
+      final session =
+          OrtSession.fromFile(File(args["imageModelPath"]), sessionOptions);
       _logger.info('image model loaded');
+
       return session.address;
     } catch (e, s) {
       _logger.severe(e, s);

+ 1 - 1
mobile/pubspec.yaml

@@ -12,7 +12,7 @@ description: ente photos application
 # Read more about iOS versioning at
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 
-version: 0.8.71+591
+version: 0.8.72+592
 publish_to: none
 
 environment: