flutter-tflite icon indicating copy to clipboard operation
flutter-tflite copied to clipboard

"Cannot create interpreter" when attempting to use XNNPackDelegate or GpuDelegateV2 (Android 13).

Open andynewman10 opened this issue 9 months ago • 3 comments

Here is what I see in the log when attempting to use the GpuDelegateV2 on Android 13 (Google Pixel 6a), as suggested in the provided example files.

I/tflite  (13058): Created TensorFlow Lite delegate for GPU.
I/tflite  (13058): Initialized TensorFlow Lite runtime.
W/libc    (13058): Access denied finding property "ro.mediatek.platform"
W/libc    (13058): Access denied finding property "ro.chipname"
W/libc    (13058): Access denied finding property "ro.hardware.chipname"

No indication is given about where the error occurred.

It is raised in interpreter.dart, here:

  factory Interpreter._create(Model model, {InterpreterOptions? options}) {
    final interpreter = tfliteBinding.TfLiteInterpreterCreate(
        model.base, options?.base ?? cast<TfLiteInterpreterOptions>(nullptr));
    checkArgument(isNotNull(interpreter),
        message: 'Unable to create interpreter.');
    return Interpreter._(interpreter);
  }

When closing the debugger session, additional red text shows up (I am not sure this is linked to the issue or maybe this is a side effect of FFI and/or the debugger):

Unhandled exception:
invalid input
#0      parseDefinitionTypes (package:front_end/src/api_prototype/expression_compilation_tools.dart:110:43)
#1      createDefinitionsWithTypes (package:front_end/src/api_prototype/expression_compilation_tools.dart:32:7)
#2      IncrementalCompiler.compileExpression (package:vm/incremental_compiler.dart:219:50)
#3      FrontendCompiler.compileExpression (package:frontend_server/frontend_server.dart:981:45)

#4      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1452:26)
#5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#8      _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
#9      _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
#10     _StringAdapterSink.add (dart:convert/string_conversion.dart:228:11)

...

Shall I give additional permissions to the application?

Similarly, the XNNPackDelegate also fails for the same model (66MB in size, which is not very big!)

andynewman10 avatar Oct 18 '23 16:10 andynewman10