Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Converts PyTorch models (e.g. ResNet, timm, HuggingFace transformers) directly to LiteRT (.tflite) flatbuffer format. Use when converting PyTorch models to TFLite, setting up export environments, or troubleshooting torch-to-litert conversion bugs. Don't use for ONNX exports or converting existing TensorFlow models.
.claude/skills/google-ai-edge-converting-pytorch-to-litert/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-15 | ✗→✓ | ▲ Improved | 31% | 0% |
| case-03 | ✗→✓ | ▲ Improved | -28% | 0% |
| case-14 | ✗→✓ | ▲ Improved | -28% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -63% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -17% | 0% |
ATTENTION ALL AGENTS: If you are tasked with converting a PyTorch model (e.g., ResNet or similar architectures) to a .tflite flatbuffer format in this repository, you must strictly follow these rules based on recent project findings:
Bypass ONNX entirely. Do not attempt to export the model to ONNX or use onnx2tf. Convert directly from PyTorch to LiteRT.
litert-torchUse the litert-torch library for the direct PyTorch to TFLite conversion. Note that ai-edge-torch is deprecated and has been officially renamed to litert-torch.
torchao (AttributeError: 'typing.Union' object has no attribute '__module__').python3.11) as it is highly recommended for stability and avoids the aforementioned type hint bugs.Before running any conversion script, ensure the following are installed in your python3.11 environment:
bashpython3.11 -m pip install torch transformers timm litert-torch ai-edge-litert litert-cli-nightly
Other measured skills in the registry, with their headline benchmark lift.