TfLiteNative

  • TfLiteNative provides access to the TensorFlow Lite (TFLite) C API from Google Play services.

  • Use initialize() to initialize the TFLite C API before calling any TFLite C functions.

  • Include necessary headers and compiler options when building C/C++ code that uses the TFLite C API provided by TfLiteNative.

  • Utilize getClient() to obtain a TfLiteClient instance for use with OptionalModuleApi.

public class TfLiteNative extends Object

Entry point for the TensorFlow Lite (TFLite) C API provided by Google Play services.

Once the initialization has finished successfully, you can use the regular Tensorflow Lite C APIs.

To build C or C++ code that uses the C API, include headers from the AAR containing this class and pass both -DTFLITE_IN_GMSCORE and -DTFLITE_WITH_STABLE_ABI options to the C (or C++) compiler.

Public Method Summary

static TfLiteClient
getClient(Context context)
Returns a TfLiteClient instance that can eventually be used as an argument for OptionalModuleApi.
static Task<Void>
initialize(Context context)
Initializes the TFLite C API with the default options.
static Task<Void>
initialize(Context context, TfLiteInitializationOptions options)
Initializes the TFLite C/C++ API with the specified options.

Inherited Method Summary

Public Methods

public static TfLiteClient getClient (Context context)

Returns a TfLiteClient instance that can eventually be used as an argument for OptionalModuleApi.

public static Task<Void> initialize (Context context)

Initializes the TFLite C API with the default options. TFLite C API functions should only be called after the task returned by this method has successfully completed.

This method returns a Task<Void>, so you should wait for the task to be completed, but the return value of the Task is irrelevant.

public static Task<Void> initialize (Context context, TfLiteInitializationOptions options)

Initializes the TFLite C/C++ API with the specified options. TFLite C/C++ API functions/methods should only be called after the task returned by this method has successfully completed.

This method returns a Task<Void>. Make sure to call TFLite API methods only after the Task has successfully completed. The return value of the Task, though, is irrelevant (will always be null).