tflite_native icon indicating copy to clipboard operation
tflite_native copied to clipboard

remove the use of `waitFor`

Open devoncarew opened this issue 5 years ago • 6 comments

We should look into removing the use of dart:cli's waitFor() method.

devoncarew avatar Nov 21 '19 19:11 devoncarew

Any proposed way how should we do it? I think we either need to find a way to synchronously resolve pakage uri (as seen in https://github.com/dart-lang/tflite_native/blob/master/lib/src/bindings/dlib.dart#L50 ) , or turn every API of this package into async

truongsinh avatar Nov 22 '19 04:11 truongsinh

I would keep all the API sync, except for a new init method. Users of the API would then need to call init(), await the response, and then use the resulting api object as normal.

This would likely change the API structure a bit. Instead of everything being a top level method, clients would instead invoke method on something like an MLBindings object. At a very rough sketch, something like this:


Future<MLBindings> init() {
   ...
}

class MLBindings {
  final DynamicLibrary _dynamicLibrary;
  
  MLBindings._(this._dynamicLibrary);

  String get version {
    Pointer<Utf8> Function() TfLiteVersion = _dynamicLibrary
        .lookup<NativeFunction<_TfLiteVersion_native_t>>('TfLiteVersion')
        .asFunction();
    return Utf8.fromUtf8(TfLiteVersion());
  }
}

That's a fairly darty version of the API. There are likely some refactorings that would mean a lot fewer changes to the current API - the API would be closer to the existing native tensorflow lite API, but be less idiomatic dart.

devoncarew avatar Nov 22 '19 16:11 devoncarew

cc @bwilkerson @lambdabaa

devoncarew avatar Nov 22 '19 16:11 devoncarew

Is there any progress on the proposal for this one?

truongsinh avatar Feb 02 '20 11:02 truongsinh

cc @devoncarew @bwilkerson @lambdabaa

truongsinh avatar Feb 11 '20 10:02 truongsinh

ping @devoncarew @bwilkerson @lambdabaa @mit-mit @eseidelGoogle

truongsinh avatar Mar 17 '20 23:03 truongsinh