Repository navigation
Add memory options, TFLite migration, and Play services snippets for the litert-runtime skill - #1348
john-rocky wants to merge 5 commits into
Conversation
…the litert-runtime skill The Play services code is in a new :ai:litert-play-services app module, because the skill says never to put play-services-litert and com.google.ai.edge.litert:litert in the same build variant.
This removes the :ai:litert-play-services module. In ai, play-services-litert is compileOnly, so it stays out of the ai app, which ships com.google.ai.edge.litert:litert.
|
Yes, these snippets are now in the |
kkuan2011
left a comment
There was a problem hiding this comment.
Could you also get a teammate who's more familiar with the code to approve?
| implementation(libs.google.adk.core.android) | ||
| ksp(libs.google.adk.processor) | ||
| implementation(libs.mlkit.genai.prompt) | ||
| implementation(libs.litert) |
There was a problem hiding this comment.
nit this list of dependencies is a little hard to read now, I would prefer if the whole list was grouped by implemention, testImpelmentation, etc.. and then alphabetized within those lists. But I don't want to cause a bigger diff than necessary on this file.
There was a problem hiding this comment.
I'll keep the current order here so the diff doesn't grow.
|
@smilingday, could you review and approve this pull request, as @kkuan2011 asked above? If you can, please also review and approve #1336 (the follow-up to your #1186) and #1340, which are waiting for approval too. |
Adds Kotlin snippets for the parts of the litert-runtime skill that #1336's CompiledModel snippets don't cover: the memory options of Step 2, the migration from the legacy TFLite Interpreter, and LiteRT in Google Play services.
The two Play services regions, which create the
Environmentand load the model with it, are inai. They needplay-services-litert, which the skill says never to put in the same build variant ascom.google.ai.edge.litert:litert, a dependency ofai: that variant's APK would carry both runtimes. Soaihasplay-services-litertascompileOnly, which keeps it out of theaiapp: the two regions compile, but they can't run in that app. Their file,LiteRtPlayServicesSnippets.kt, also has copies of #1336'sClassifierandMainViewModel, changed to use theEnvironmentfrom Play services, so the file builds without #1336.Apart from imports and formatting, one of the 12 regions differs from the skill's blocks at android/skills commit 7f7b2173.
android_litert_runtime_skill_play_services_loadhas one more line,if (classifier != null) return@launch, after theEnvironmentis awaited and before aClassifieris created. If anotherloadcall created aClassifierduring that wait, the waiting coroutine stops at that line and creates no second one.As suggested in the review of #1186, the imports and the dependency lines this PR adds have no region tags: the imports-only block of references/migration.md and the Gradle blocks stay in the skill.
aigets the samelitertandlitert-gpu2.4.1 lines as #1336, pluslitert-support2.4.1 forandroid_litert_runtime_skill_migration_support_image. My other pull requests, #1336 and #1340, add dependency lines inai/build.gradle.ktsandgradle/libs.versions.tomlat some of the same places as this one. A plain merge of this branch with either of them conflicts in both files. After each merge, I'll update whichever of the three are still open.Testing
build,spotlessCheckandextractSnippetstasks ofaisucceed, andextractSnippetsextracts the 12 regions.ai, the 21aitests ported fromMemoryOptionsTestandMigrationCodeTestin google-ai-edge/litert-samples passed on a Pixel 8a. The test code is not part of this pull request.