am15h / tflite_flutter_plugin

TensorFlow Lite Flutter Plugin
https://pub.dev/packages/tflite_flutter
Apache License 2.0
507 stars 353 forks source link

[Question] How to check if a certain backend is available? #179

Open CaptainDario opened 2 years ago

CaptainDario commented 2 years ago

How can one check if a certain backend is available on the current device?

For example, not all android devices support the GPU delegate, when used anyways, the app crashes. Therefore I am interested in a way to check which backends are available on the current device.

CaptainDario commented 2 years ago

Some progress: For NNAPI you can simply check if the android SDK version is >= 27 (docs about this).

example:

// use NNAPI on android if android API >= 27
if (androidInfo.version.sdkInt! >= 27) {
  interpreter = await _nnapiInterpreter();
}