LiteRT Next는 특히 기기 내 ML 및 AI 애플리케이션의 하드웨어 가속 및 성능 측면에서 LiteRT를 개선한 새로운 API 세트입니다. 이 API는 알파 버전이며 Kotlin과 C++에서 사용할 수 있습니다.
LiteRT Next Compiled Model API는 TensorFlow Lite 인터프리터 API를 기반으로 하며 기기 내 머신러닝을 위한 모델 로드 및 실행 프로세스를 간소화합니다. 새로운 API는 하드웨어 가속을 사용하는 새로운 간소화된 방법을 제공하므로 모델 FlatBuffers, I/O 버퍼 상호 운용성, 대리자를 처리할 필요가 없습니다. LiteRT Next API는 LiteRT API와 호환되지 않습니다. LiteRT Next의 기능을 사용하려면 시작하기 가이드를 참고하세요.
// Load model and initialize runtimeLITERT_ASSIGN_OR_RETURN(automodel,Model::CreateFromFile("mymodel.tflite"));LITERT_ASSIGN_OR_RETURN(autoenv,Environment::Create({}));LITERT_ASSIGN_OR_RETURN(autocompiled_model,CompiledModel::Create(env,model,kLiteRtHwAcceleratorCpu));// Preallocate input/output buffersLITERT_ASSIGN_OR_RETURN(autoinput_buffers,compiled_model.CreateInputBuffers());LITERT_ASSIGN_OR_RETURN(autooutput_buffers,compiled_model.CreateOutputBuffers());// Fill the first inputfloatinput_values[]={/* your data */};input_buffers[0].Write<float>(absl::MakeConstSpan(input_values,/*size*/));// Invokecompiled_model.Run(input_buffers,output_buffers);// Read the outputstd::vector<float>data(output_data_size);output_buffers[0].Read<float>(absl::MakeSpan(data));
Kotlin
// Load model and initialize runtimevalmodel=CompiledModel.create(context.assets,"mymodel.tflite",CompiledModel.Options(Accelerator.CPU))// Preallocate input/output buffersvalinputBuffers=model.createInputBuffers()valoutputBuffers=model.createOutputBuffers()// Fill the first inputinputBuffers[0].writeFloat(FloatArray(data_size){data_value/* your data */})// Invokemodel.run(inputBuffers,outputBuffers)// Read the outputvaloutputFloatArray=outputBuffers[0].readFloat()
새로운 LiteRT API: 자동화된 가속기 선택, 진정한 비동기 실행, 효율적인 I/O 버퍼 처리를 통해 개발을 간소화합니다.
최고의 GPU 성능: 기기 내 ML에 최신 GPU 가속을 사용합니다. 새로운 버퍼 상호 운용성을 통해 제로 복사를 사용 설정하고 다양한 GPU 버퍼 유형에서 지연 시간을 최소화할 수 있습니다.
우수한 생성형 AI 추론: 생성형 AI 모델에 최적의 성능으로 가장 간단하게 통합할 수 있습니다.
통합 NPU 가속: 일관된 개발자 환경을 통해 주요 칩셋 제공업체의 NPU에 원활하게 액세스할 수 있습니다. LiteRT NPU 가속은 사전 체험 프로그램을 통해 사용할 수 있습니다.
주요 개선사항
LiteRT Next (컴파일된 모델 API)에는 LiteRT (TFLite 인터프리터 API)의 다음과 같은 주요 개선사항이 포함되어 있습니다. LiteRT Next로 애플리케이션을 설정하는 방법에 관한 포괄적인 가이드는 시작하기 가이드를 참고하세요.
가속기 사용: LiteRT를 사용하여 GPU에서 모델을 실행하려면 명시적 대리자 생성, 함수 호출, 그래프 수정이 필요합니다. LiteRT를 사용하면 다음과 같이 가속기를 지정하기만 하면 됩니다.
네이티브 하드웨어 버퍼 상호 운용성: LiteRT는 버퍼 옵션을 제공하지 않으며 모든 데이터를 CPU 메모리를 통해 강제합니다. LiteRT Next를 사용하면 Android 하드웨어 버퍼 (AHWB), OpenCL 버퍼, OpenGL 버퍼 또는 기타 특수 버퍼를 전달할 수 있습니다.
비동기 실행: LiteRT Next에는 동기화 울타리를 기반으로 하는 진정한 비동기 메커니즘을 제공하는 새롭게 설계된 비동기 API가 제공됩니다. 이를 통해 다양한 태스크에 CPU, GPU, CPU, NPU와 같은 다양한 하드웨어를 사용하여 전반적인 실행 시간을 단축할 수 있습니다.
모델 로드: LiteRT Next는 모델을 로드할 때 별도의 빌더 단계가 필요하지 않습니다.
[[["이해하기 쉬움","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,["# LiteRT Next Overview\n\n| **Experimental:** LiteRT Next is an alpha release and under active development.\n\nLiteRT Next is a new set of APIs that improves upon LiteRT, particularly in\nterms of hardware acceleration and performance for on-device ML and AI\napplications. The APIs are an alpha release and available in Kotlin and C++.\n\nThe LiteRT Next Compiled Model API builds on the TensorFlow Lite Interpreter\nAPI, and simplifies the model loading and execution process for on-device\nmachine learning. The new APIs provide a new streamlined way to use hardware\nacceleration, removing the need to deal with model FlatBuffers, I/O buffer\ninteroperability, and delegates. The LiteRT Next APIs are not compatible with\nthe LiteRT APIs. In order to use features from LiteRT Next, see the [Get\nStarted](./get_started) guide.\n\nFor example implementations of LiteRT Next, refer to the following demo\napplications:\n\n- [Image segmentation with Kotlin](https://github.com/google-ai-edge/LiteRT/tree/main/litert/samples/image_segmentation/kotlin_cpu_gpu/android)\n- [Asynchronous segmentation with C++](https://github.com/google-ai-edge/LiteRT/tree/main/litert/samples/async_segmentation)\n\nQuickstart\n----------\n\nRunning inference with the LiteRT Next APIs involves the following key steps:\n\n1. Load a compatible model.\n2. Allocate the input and output tensor buffers.\n3. Invoke the compiled model.\n4. Read the inferences into an output buffer.\n\nThe following code snippets show a basic implementation of the entire process in\nKotlin and C++. \n\n### C++\n\n // Load model and initialize runtime\n LITERT_ASSIGN_OR_RETURN(auto model, Model::CreateFromFile(\"mymodel.tflite\"));\n LITERT_ASSIGN_OR_RETURN(auto env, Environment::Create({}));\n LITERT_ASSIGN_OR_RETURN(auto compiled_model,\n CompiledModel::Create(env, model, kLiteRtHwAcceleratorCpu));\n\n // Preallocate input/output buffers\n LITERT_ASSIGN_OR_RETURN(auto input_buffers, compiled_model.CreateInputBuffers());\n LITERT_ASSIGN_OR_RETURN(auto output_buffers, compiled_model.CreateOutputBuffers());\n\n // Fill the first input\n float input_values[] = { /* your data */ };\n input_buffers[0].Write\u003cfloat\u003e(absl::MakeConstSpan(input_values, /*size*/));\n\n // Invoke\n compiled_model.Run(input_buffers, output_buffers);\n\n // Read the output\n std::vector\u003cfloat\u003e data(output_data_size);\n output_buffers[0].Read\u003cfloat\u003e(absl::MakeSpan(data));\n\n### Kotlin\n\n // Load model and initialize runtime\n val model =\n CompiledModel.create(\n context.assets,\n \"mymodel.tflite\",\n CompiledModel.Options(Accelerator.CPU)\n )\n\n // Preallocate input/output buffers\n val inputBuffers = model.createInputBuffers()\n val outputBuffers = model.createOutputBuffers()\n\n // Fill the first input\n inputBuffers[0].writeFloat(FloatArray(data_size) { data_value /* your data */ })\n\n // Invoke\n model.run(inputBuffers, outputBuffers)\n\n // Read the output\n val outputFloatArray = outputBuffers[0].readFloat()\n\nFor more information, see the [Get Started with Kotlin](./android_kotlin) and\n[Get Started with C++](./android_cpp) guides.\n\nKey features\n------------\n\nLiteRT Next contains the following key benefits and features:\n\n- **New LiteRT API**: Streamline development with automated accelerator selection, true async execution, and efficient I/O buffer handling.\n- **Best-in-class GPU Performance**: Use state-of-the-art GPU acceleration for on-device ML. The new buffer interoperability enables zero-copy and minimizes latency across various GPU buffer types.\n- **Superior Generative AI inference**: Enable the simplest integration with the best performance for GenAI models.\n- **Unified NPU Acceleration** : Offer seamless access to NPUs from major chipset providers with a consistent developer experience. LiteRT NPU acceleration is available through an [Early Access\n Program](https://forms.gle/CoH4jpLwxiEYvDvF6).\n\nKey improvements\n----------------\n\nLiteRT Next (Compiled Model API) contains the following key improvements on\nLiteRT (TFLite Interpreter API). For a comprehensive guide to setting up your\napplication with LiteRT Next, see the [Get Started](./get_started) guide.\n\n- **Accelerator usage**: Running models on GPU with LiteRT requires explicit delegate creation, function calls, and graph modifications. With LiteRT Next, just specify the accelerator.\n- **Native hardware buffer interoperability**: LiteRT does not provide the option of buffers, and forces all data through CPU memory. With LiteRT Next, you can pass in Android Hardware Buffers (AHWB), OpenCL buffers, OpenGL buffers, or other specialized buffers.\n- **Async execution**: LiteRT Next comes with a redesigned async API, providing a true async mechanism based on sync fences. This enables faster overall execution times through the use of diverse hardware -- like CPUs, GPUs, CPUs, and NPUs -- for different tasks.\n- **Model loading**: LiteRT Next does not require a separate builder step when loading a model."]]