TfLiteNative
Stay organized with collections
Save and categorize content based on your preferences.
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 |
|
static Task< Void
> |
|
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
Public Methods
public static TfLiteClient
getClient
( Context
context)
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
).
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eTfLiteNative\u003c/code\u003e provides access to the TensorFlow Lite (TFLite) C API from Google Play services.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003einitialize()\u003c/code\u003e to initialize the TFLite C API before calling any TFLite C functions.\u003c/p\u003e\n"],["\u003cp\u003eInclude necessary headers and compiler options when building C/C++ code that uses the TFLite C API provided by \u003ccode\u003eTfLiteNative\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eUtilize \u003ccode\u003egetClient()\u003c/code\u003e to obtain a \u003ccode\u003eTfLiteClient\u003c/code\u003e instance for use with \u003ccode\u003eOptionalModuleApi\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# TfLiteNative\n\npublic class **TfLiteNative** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nEntry point for the TensorFlow Lite (TFLite) C API provided by Google Play services.\n\nOnce the initialization has finished successfully, you can use [the regular Tensorflow Lite C APIs](/android/reference/com/google/android/gms/tflite/java/www.tensorflow.org/code/tensorflow/lite/c).\n\nTo build C or C++ code that uses the C API, include headers from the AAR containing this\nclass and pass both `-DTFLITE_IN_GMSCORE` and\n`-DTFLITE_WITH_STABLE_ABI` options to the C (or C++) compiler. \n\n### Public Method Summary\n\n|------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static TfLiteClient | [getClient](/android/reference/com/google/android/gms/tflite/java/TfLiteNative#getClient(android.content.Context))([Context](//developer.android.com/reference/android/content/Context.html) context) Returns a [TfLiteClient](/android/reference/com/google/android/gms/tflite/client/TfLiteClient) instance that can eventually be used as an argument for [OptionalModuleApi](/android/reference/com/google/android/gms/common/api/OptionalModuleApi). |\n| static Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [initialize](/android/reference/com/google/android/gms/tflite/java/TfLiteNative#initialize(android.content.Context))([Context](//developer.android.com/reference/android/content/Context.html) context) Initializes the TFLite C API with the default options. |\n| static Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [initialize](/android/reference/com/google/android/gms/tflite/java/TfLiteNative#initialize(android.content.Context,%20com.google.android.gms.tflite.client.TfLiteInitializationOptions))([Context](//developer.android.com/reference/android/content/Context.html) context, TfLiteInitializationOptions options) Initializes the TFLite C/C++ API with the specified options. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public static TfLiteClient\n**getClient** ([Context](//developer.android.com/reference/android/content/Context.html) context)\n\nReturns a [TfLiteClient](/android/reference/com/google/android/gms/tflite/client/TfLiteClient)\ninstance that can eventually be used as an argument for [OptionalModuleApi](/android/reference/com/google/android/gms/common/api/OptionalModuleApi). \n\n#### public static Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **initialize** ([Context](//developer.android.com/reference/android/content/Context.html) context)\n\nInitializes the TFLite C API with the default options. TFLite C API functions should\nonly be called after the task returned by this method has successfully completed.\n\nThis method returns a `Task\u003cVoid\u003e`, so you should wait for the task\nto be completed, but the return value of the Task is irrelevant. \n\n#### public static Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **initialize** ([Context](//developer.android.com/reference/android/content/Context.html) context, TfLiteInitializationOptions options)\n\nInitializes the TFLite C/C++ API with the specified options. TFLite C/C++ API\nfunctions/methods should only be called after the task returned by this method has\nsuccessfully completed.\n\nThis method returns a `Task\u003cVoid\u003e`. Make sure to call TFLite API\nmethods only after the `Task` has successfully completed. The return value\nof the `Task`, though, is irrelevant (will always be `null`)."]]