所有针对 Google 设备端 AI 高性能运行时的全新开发工作都将专门在 LiteRT 上进行。使用 TensorFlow Lite 软件包的应用将继续运行,但所有新更新都将仅包含在 LiteRT 软件包中。LiteRT API 包含与 TF Lite API 相同的方法名称,因此迁移到 LiteRT 不需要进行详细的代码更改。
Play 服务运行时中的 LiteRT 会继续使用 play-services-tflite 依赖项。如果您的应用已在使用 Play 服务运行时和 TensorFlow Lite,则无需进行任何代码更改。
如需在 Play 服务中使用 LiteRT,请将以下代码添加到您的 build.gradle 依赖项中:
dependencies{...// LiteRT dependencies for Google Play servicesimplementation'com.google.android.gms:play-services-tflite-java:16.4.0'// Optional: include LiteRT Support Libraryimplementation'com.google.android.gms:play-services-tflite-support:16.4.0'...}
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-24。"],[],[],null,["# Migrate to LiteRT from TensorFlow Lite\n\n| **Note:** This page is for users migrating from TF Lite to LiteRT. To migrate to LiteRT Next, see [Get Started with LiteRT Next](./next/get_started).\n\nAll new development for Google's high-performance runtime for on-device AI will\nbe exclusively on LiteRT. Applications that use TensorFlow Lite packages will\ncontinue to function, but all new updates will only be included in LiteRT\npackages. The LiteRT APIs contain the same method names as the TF Lite APIs, so\nmigrating to LiteRT does not require detailed code changes.\n\nFor package name changes, see the following migration guides for specific\nplatforms.\n\nMigrate with Android\n--------------------\n\nTo migrate an Android application using Tensorflow Lite, replace the dependency\nfrom `org.tensorflow:tensorflow-lite` to `com.google.ai.edge.litert`. The\n[LiteRT Maven repository](https://maven.google.com/web/index.html#com.google.ai.edge.litert)\nincludes the following packages:\n\n- [`com.google.ai.edge.litert:litert`](https://maven.google.com/web/index.html#com.google.ai.edge.litert:litert)\n- [`com.google.ai.edge.litert:litert-gpu`](https://maven.google.com/web/index.html#com.google.ai.edge.litert:litert-gpu)\n- [`com.google.ai.edge.litert:litert-metadata`](https://maven.google.com/web/index.html#com.google.ai.edge.litert:litert-metadata)\n- [`com.google.ai.edge.litert:litert-support`](https://maven.google.com/web/index.html#com.google.ai.edge.litert:litert-support)\n\nYou can make this change in your `build.gradle` dependencies: \n\n dependencies {\n ...\n implementation `com.google.ai.edge.litert:litert:1.0.1`\n }\n\n### Play Services\n\nLiteRT in the Play Services runtime continues to use the `play-services-tflite`\ndependency. If your app is already using the Play Services runtime with\nTensorFlow Lite, you don't need to make any code changes.\n\nTo use LiteRT in Play Services, add the following to your `build.gradle`\ndependencies: \n\n dependencies {\n ...\n // LiteRT dependencies for Google Play services\n implementation 'com.google.android.gms:play-services-tflite-java:16.4.0'\n // Optional: include LiteRT Support Library\n implementation 'com.google.android.gms:play-services-tflite-support:16.4.0'\n ...\n }\n\nMigrate with Python\n-------------------\n\nTo migrate Python code using Tensorflow Lite, replace the PIP package from\n`tflite-runtime` to `ai-edge-litert`.\n\nInstall LiteRT with PIP: \n\n $ python3 -m pip install ai-edge-litert\n\nImport LiteRT with the following: \n\n from ai_edge_litert.interpreter import Interpreter\n interpreter = Interpreter(model_path=args.model_file)\n\nOther Libraries\n---------------\n\nThe Swift and Objective-C SDKs for iOS, C++ SDK, Task Library, and Model Maker\nlibrary continues to exist in the TensorFlow Lite APIs. Applications using these\nSDKs or libraries shouldn't migrate to LiteRT."]]