@google-ai-edge/converting-pytorch-to-litert
AConverts 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.
Install
agr install @google-ai-edge/converting-pytorch-to-litert --target claudeWrites 15 files into .claude/skills/, pinned to git-433c10fa.
- .claude/skills/converting-pytorch-to-litert/.bazelrc
- .claude/skills/converting-pytorch-to-litert/.bazelversion
- .claude/skills/converting-pytorch-to-litert/.gitignore
- .claude/skills/converting-pytorch-to-litert/.isort.cfg
- .claude/skills/converting-pytorch-to-litert/CONTRIBUTING.md
- .claude/skills/converting-pytorch-to-litert/LICENSE
- .claude/skills/converting-pytorch-to-litert/MODULE.bazel
- .claude/skills/converting-pytorch-to-litert/README.md
- .claude/skills/converting-pytorch-to-litert/SKILL.md
- .claude/skills/converting-pytorch-to-litert/WORKSPACE
- .claude/skills/converting-pytorch-to-litert/dev-requirements.txt
- .claude/skills/converting-pytorch-to-litert/format.sh
- .claude/skills/converting-pytorch-to-litert/requirements.txt
- .claude/skills/converting-pytorch-to-litert/run_tests.sh
- .claude/skills/converting-pytorch-to-litert/setup.py
Document
name: converting-pytorch-to-litert description: >- 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.
PyTorch to LiteRT Conversion Guide
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:
1. Direct Conversion Only (No ONNX)
Bypass ONNX entirely. Do not attempt to export the model to ONNX or use onnx2tf. Convert directly from PyTorch to LiteRT.
2. Use litert-torch
Use 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.
3. Strict Python Environment Rules
- Do NOT use Python 3.14. It currently has compatibility issues with typing in
torchao(AttributeError: 'typing.Union' object has no attribute '__module__'). - Use Python 3.11 (e.g.,
python3.11) as it is highly recommended for stability and avoids the aforementioned type hint bugs.
4. Dependencies
Before running any conversion script, ensure the following are installed in your python3.11 environment:
python3.11 -m pip install torch transformers timm litert-torch ai-edge-litert litert-cli-nightly
Trustgrade A
- passBody integrity
Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.
- passType matchnot applicable to this artifact type
Whether the artifact is really the kind of thing its metadata claims it is.
- passFreshness
How long since the source repository was last pushed to.
- passPrompt injection
Scans the artifact's own text for instructions aimed at your agent rather than at you.
- passLicense
Whether the source repository declares an SPDX license permissive enough to redistribute.
How the grade is calculated
Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:
- Aevery check passed
- Bone warning
- Ctwo warnings
- Dprompt injection or body integrity failed, or three warnings
- Fone of those failed, and something else is wrong
These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.
Versions
git-433c10faa77b2026-07-31