Skip to main content

converting-pytorch-to-litert

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.

소스 정보

저장소
google-ai-edge/litert-torch
최근 소스 활동
2026년 10월 25일 21:16
감지된 SKILL.md 언어
영어
스타
1,109
포크
189

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
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: ```bash python3.11 -m pip install torch transformers timm litert-torch ai-edge-litert litert-cli-nightly
GitHub에서 보기