AI Edge Torch는 PyTorch 모델을 .tflite 형식으로 변환하여 LiteRT 및 MediaPipe로 이러한 모델을 실행할 수 있는 라이브러리입니다.
이는 모델을 완전히 기기 내에서 실행하는 모바일 앱을 만드는 개발자에게 특히 유용합니다. AI Edge Torch는 초기 GPU 및 NPU 지원과 함께 광범위한 CPU 적용 범위를 제공합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-24(UTC)"],[],[],null,["# Convert PyTorch models to LiteRT\n\nAI Edge Torch is a library that lets you convert PyTorch models into a `.tflite`\nformat, enabling you to run those models with LiteRT and MediaPipe.\nThis is especially helpful for developers creating mobile apps that run models\ncompletely on-device. AI Edge Torch offers broad CPU coverage, with initial GPU\nand NPU support.\n\nTo get started converting PyTorch models to LiteRT, use the [Pytorch converter\nquickstart](./pytorch_to_tflite). For more information, see the AI Edge Torch\n[GitHub repo](https://github.com/google-ai-edge/ai-edge-torch/).\n\nIf you are specifically converting Large Language Models (LLMs) or\ntransformer-based models, use the [Generative Torch API](./edge_generative),\nwhich handles transformer-specific conversion details like model authoring and\nquantization.\n\nConversion workflow\n-------------------\n\nThe following steps demonstrate a simple end-to-end conversion of a PyTorch\nmodel to LiteRT.\n\n### Import AI Edge Torch\n\nStart by importing the AI Edge Torch (`ai-edge-torch`) pip package, along with\nPyTorch. \n\n import ai_edge_torch\n import torch\n\nFor this example, we also require the following packages: \n\n import numpy\n import torchvision\n\n### Initialize and convert the model\n\nWe will convert\n[ResNet18](https://pytorch.org/vision/main/models/generated/torchvision.models.resnet18.html),\na popular image recognition model. \n\n resnet18 = torchvision.models.resnet18(torchvision.models.ResNet18_Weights.IMAGENET1K_V1).eval()\n\nUse the `convert` method from the AI Edge Torch library to convert the PyTorch\nmodel. \n\n sample_input = (torch.randn(1, 3, 224, 224),)\n edge_model = ai_edge_torch.convert(resnet18.eval(), sample_input)\n\n### Use the model\n\nAfter converting the Pytorch model, you can run inferences with the new\nconverted LiteRT model. \n\n output = edge_model(*sample_inputs)\n\nYou can export and save the converted model in the `.tflite` format for future\nuse. \n\n edge_model.export('resnet.tflite')"]]