agentsclimarketplace

Litert skill

Skill farmhutsoftwareteam/litert-skill

Google's on-device AI framework for deploying ML and GenAI models on edge devices (successor to TensorFlow Lite). Use when working with on-device inference, .tflite models, mobile ML deployment, GPU/NPU acceleration, LiteRT-LM for LLMs, model conversion from PyTorch/TensorFlow/JAX, or migrating from TensorFlow Lite. Triggers on Android/iOS/Web ML inference, CompiledModel API, hardware acceleration, edge AI deployment, or running models like Gemma on device.From its SKILL.md

Install
npx -y skills add farmhutsoftwareteam/litert-skill

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

4.4 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it

LiteRT: On-Device AI Framework

Overview

LiteRT (Lite Runtime) is Google's framework for deploying ML and generative AI on edge devices. It's the successor to TensorFlow Lite with advanced GPU/NPU acceleration delivering up to 100x faster inference than CPU.

Platform Support

PlatformCPUGPUNPU
AndroidYesOpenCL, OpenGLQualcomm, MediaTek
iOSYesMetalANE (coming)
macOSYesMetal, WebGPUANE (coming)
WindowsYesWebGPUIntel (coming)
LinuxYesWebGPU-
WebYesWebGPUComing

Quick Start

Android (Kotlin)

// Add dependency: implementation 'com.google.ai.edge.litert:litert:2.1.0'

val model = CompiledModel.create(
    context.assets,
    "model.tflite",
    CompiledModel.Options(Accelerator.GPU)  // or NPU, CPU
)

val inputBuffers = model.createInputBuffers()
val outputBuffers = model.createOutputBuffers()

inputBuffers[0].writeFloat(inputData)
model.run(inputBuffers, outputBuffers)
val result = outputBuffers[0].readFloat()

C++

#include "litert/cc/litert_compiled_model.h"
#include "litert/cc/litert_environment.h"

LITERT_ASSIGN_OR_RETURN(auto env, Environment::Create({}));
LITERT_ASSIGN_OR_RETURN(auto compiled_model,
    CompiledModel::Create(env, "model.tflite", kLiteRtHwAcceleratorGpu));

LITERT_ASSIGN_OR_RETURN(auto inputs, compiled_model.CreateInputBuffers());
LITERT_ASSIGN_OR_RETURN(auto outputs, compiled_model.CreateOutputBuffers());
compiled_model.Run(inputs, outputs);

Python

from ai_edge_litert.interpreter import Interpreter

interpreter = Interpreter(model_path='model.tflite')
interpreter.allocate_tensors()
interpreter.set_tensor(input_index, input_data)
interpreter.invoke()
output = interpreter.get_tensor(output_index)

APIs

CompiledModel API (Recommended)

  • Modern API for hardware acceleration
  • Supports GPU, NPU, CPU
  • Zero-copy buffer interop
  • Async execution

Interpreter API (Legacy)

  • TensorFlow Lite compatible
  • CPU-only in v2.x
  • Use for backward compatibility

Task Decision Tree

Running inference on device?

Deploying LLMs (Gemma, Phi, Qwen)?

Converting models to .tflite?

  • PyTorch: Use litert-torch package
  • TensorFlow: Use tf.lite.TFLiteConverter
  • JAX: Use jax2tf bridge
  • See model-conversion.md

Migrating from TensorFlow Lite?

Performance Tips

  1. Choose the right accelerator: NPU > GPU > CPU for most models
  2. Use zero-copy buffers: Pass camera/GPU buffers directly
  3. Enable async execution: Overlap CPU/GPU work
  4. Cache NPU compilation: Use CompilerCacheDir environment option
  5. Quantize models: INT8 reduces size 4x, improves speed

Dependencies

Android (Gradle)

implementation 'com.google.ai.edge.litert:litert:2.1.0'

Python

pip install ai-edge-litert           # Runtime
pip install litert-torch             # PyTorch conversion
pip install ai-edge-quantizer        # Quantization

Resources

Reference Files

What ships with it: 7 files

21.2 KB alongside SKILL.md

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.