You can use prebuilt C++ libraries in your applications without building the entire LiteRT source tree. The integration can be done with CMake.
The following shows basic steps to use LiteRT CompiledModel
API in your C++
code.
Download prebuilt LiteRT runtime shared library
Download the LiteRT runtime shared library by following the links:
| Platform | Version | LiteRT runtime library |
|---|---|---|
|
android_arm64
|
2.1.5 | libLiteRt.so |
|
android_x86_64
|
2.1.5 | libLiteRt.so |
|
linux_x86_64
|
2.1.5 | libLiteRt.so |
|
linux_arm64
|
2.1.5 | libLiteRt.so |
|
ios_arm64
|
2.1.5 | libLiteRt.dylib |
|
ios_sim_arm64
|
2.1.5 | libLiteRt.dylib |
|
macos_arm64
|
2.1.5 | libLiteRt.dylib |
|
windows_x86_64
|
2.1.5 | libLiteRt.dll |
Download prebuilt GPU Accelerators
If you need GPU Acceleration, you need GPU Accelerator. Since it's not open sourced yet, you need to download prebuilts.
Here are available GPU Accelerators.
| Platform | Version | GPU Accelerator | Backend |
|---|---|---|---|
|
android_arm64
|
2.1.5 | libLiteRtClGlAccelerator.so | OpenCL + OpenGL |
|
android_x86_64
|
2.1.5 | libLiteRtClGlAccelerator.so | OpenCL + OpenGL |
|
linux_x86_64
|
2.1.5 | libLiteRtWebGpuAccelerator.so | WebGPU (Vulkan) |
|
linux_arm64
|
2.1.5 | libLiteRtWebGpuAccelerator.so | WebGPU (Vulkan) |
|
ios_arm64
|
2.1.5 | libLiteRtMetalAccelerator.dylib | Metal |
|
ios_sim_arm64
|
2.1.5 | libLiteRtMetalAccelerator.dylib | Metal |
|
macos_arm64
|
2.1.5 | libLiteRtMetalAccelerator.dylib | Metal |
|
windows_x86_64
|
2.1.5 | libLiteRtWebGpuAccelerator.dll | WebGPU (Direct3D) |
Prepare prebuilt LiteRT C++ library
Choose a folder to host LiteRT C++ SDK. We'll refer to it as <litert_cc_sdk_location>
.
-
Download C++ SDK
You need to prepare the necessary files (CMakeLists.txt, source and header files) from LiteRT C++ SDK zip file under
<litert_cc_sdk_location>.wget https://github.com/google-ai-edge/LiteRT/releases/<litert_version>/download/litert_cc_sdk.zip unzip litert_cc_sdk.zip -d <litert_cc_sdk_location> -
Place the downloaded
libLiteRt.sounder<litert_cc_sdk_location>.cp <path_to_prebuilt_lib>/libLiteRt.so <litert_cc_sdk_location>/litert_cc_sdk/ -
Build library and
run_model_simpletool.LiteRT needs
clangto build. Configure C++ SDK and build tools as the following:cd <litert_cc_sdk_location> cmake -S litert_cc_sdk -B litert_cc_sdk_build -DCMAKE_C_COMPILER = clang -DCMAKE_CXX_COMPILER = clang++ cmake --build litert_cc_sdk_build -j
Integrate prebuilt LiteRT C++ library
-
Update your
CMakeLists.txtto use LiteRT API.add_subdirectory ( "<litert_cc_sdk_location>" "<litert_cc_sdk_location>/build" ) include_directories ( "<litert_cc_sdk_location>" ) target_link_libraries ( ${ CMAKE_PROJECT_NAME } # Use `litert_cc_api` for LiteRT C++ SDK litert_cc_api android log )

