TfLiteNative

  • TfLiteNative is the entry point for the TensorFlow Lite C API provided by Google Play services.

  • After successful initialization, 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 and pass specific compiler options.

  • ThegetClient method returns a TfLiteClient instance.

  • Theinitialize method (with or without options) initializes the TFLite C/C++ API and must complete successfully before using TFLite C API functions.

public classTfLiteNative extendsObject

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

Once the initialization has finished successfully, you can usethe 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 aTfLiteClient instance that can eventually be used as an argument forOptionalModuleApi.
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

From class java.lang.Object
Object
clone()
boolean
equals(Object arg0)
void
finalize()
finalClass<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()

Public Methods

public static TfLiteClientgetClient(Context context)

Returns aTfLiteClient instance that can eventually be used as an argument forOptionalModuleApi.

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 aTask<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 aTask<Void>. Make sure to call TFLite API methods only after theTask has successfully completed. The return value of theTask, though, is irrelevant (will always benull).

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-10-31 UTC.