Migrate to LiteRT from TensorFlow Lite

All new development for Google's high-performance runtime for on-device AI will be exclusively on LiteRT. Applications that use TensorFlow Lite packages will continue to function, but all new updates will only be included in LiteRT packages. The LiteRT APIs contain the same method names as the TF Lite APIs, so migrating to LiteRT does not require detailed code changes.

For package name changes, see the following migration guides for specific platforms.

Migrate with Android

To migrate an Android application using Tensorflow Lite, replace the dependency from org.tensorflow:tensorflow-lite to com.google.ai.edge.litert. The LiteRT Maven repository includes the following packages:

You can make this change in your build.gradle dependencies:

dependencies {
  ...
  implementation `com.google.ai.edge.litert:litert:1.0.1`
}

Play Services

LiteRT in the Play Services runtime continues to use the play-services-tflite dependency. If your app is already using the Play Services runtime with TensorFlow Lite, you don't need to make any code changes.

To use LiteRT in Play Services, add the following to your build.gradle dependencies:

dependencies {
...
    // LiteRT dependencies for Google Play services
    implementation 'com.google.android.gms:play-services-tflite-java:16.0.1'
    // Optional: include LiteRT Support Library
    implementation 'com.google.android.gms:play-services-tflite-support:16.0.1'
...
}

Migrate with Python

To migrate Python code using Tensorflow Lite, replace the PIP package from tflite-runtime to ai-edge-litert.

Install LiteRT with PIP:

$ python3 -m pip install ai-edge-litert

Import LiteRT with the following:

from ai_edge_lite.interpreter import Interpreter
interpreter = Interpreter(model_path=args.model_file)

Other Libraries

The Swift and Objective-C SDKs for iOS, C++ SDK, Task Library, and Model Maker library continues to exist in the TensorFlow Lite APIs. Applications using these SDKs or libraries shouldn't migrate to LiteRT.