
Key points
- The LiteRT Tensor API allows native C++ control over model graphs for edge devices.
- It supports running the same graph on CPU, GPU and NPU without rewriting code.
- A demo app uses SAM 2 on WebGPU, achieving over 30 frames per second.
Google Developers blog announced the release of the LiteRT Tensor API, a lightweight authoring layer within the LiteRT stack.confirmed This tool provides developers with native C++ control over model graphs. It aims to unify end-to-end machine learning computations on heterogeneous edge hardware. The announcement highlights a shift towards greater flexibility for on-device AI development.
How we got here
Shipping on-device AI typically requires meeting strict latency and memory budgets. The common path involves converting trained models, such as PyTorch models via LiteRT Torch. Google recommends this conversion route for most production projects due to its reliability. However, some developers need full control over network representation. They may want to support new architectures or test lowering logic without waiting for upstream framework updates.
What is new
Previously, ultimate control required writing computations manually in native C++ or shader languages. This approach, popularised by Apple's MLX and llama.cpp, couples implementations to specific backends like Metal or Vulkan. Developers had to rewrite code for each new hardware target. Managing buffer interoperability across CPU, GPU and NPU also demanded significant manual engineering. The new Tensor API combines native authoring flexibility with cross-platform portability.
Where this leaves builders
Developers can now build computation graphs op by op in C++. They choose exactly which operations run and how they connect. The same graph runs through LiteRT on CPU, GPU or NPU. It can also run directly on CPU via XNNPACK without a model file. This eliminates the need to rewrite code for each hardware target. Model inference and pre- or post-processing can be chained through shared accelerator buffers.
What the paper shows
The blog post describes a practical application of the Tensor API using an interactive Segment Anything App. The app runs entirely on-device in a browser on WebGPU. It enables real-time multi-object segmentation and tracking via Meta's Segment Anything Model 2.reported The SAM 2 model is fully authored in C++ via the LiteRT Tensor API.reported A coding agent wrote and evolved the implementation from under 10 to over 30 frames per second at 512x512 resolution.reported The complete implementation is open source in the LiteRT Samples GitHub repo.
Why it matters
- Enterprise IT buyers can reduce engineering overhead by avoiding backend-specific rewrites for each new edge device.
- The ability to run graphs on CPU, GPU and NPU from a single C++ source simplifies hardware procurement strategies.
- Direct weight ingestion from Hugging Face .safetensors files removes the need for intermediate conversion scripts, speeding up deployment.
- Tensor-centric buffer interop keeps intermediate data on accelerators with zero copies, potentially lowering latency for complex pipelines.
Topics: Google, LiteRT, edge AI, C++, model authoring
Updated
Ask the article
Local keyword search of this article; no generated answers.Which of these is confirmed?
Check the answer
Google Developers blog announced the release of the LiteRT Tensor API, a lightweight authoring layer within the LiteRT stack.
The matched primary source and announcement wording support the confirmed label.
Did this article give you the evidence you needed?
Your choice stays on this device. No public tally.Questions readers ask
Does the LiteRT Tensor API replace model conversion?
No, Google recommends the conversion path as the best default for most models. The Tensor API is for cases needing low-level graph control.
What hardware targets does the Tensor API support?
It supports CPU, GPU (powered by open-source ML Drift) and NPU. It can also run directly on CPU through XNNPACK.
Is the SAM 2 implementation open source?
Yes, the complete implementation and the web app are open source in the LiteRT Samples GitHub repo.
Connected stories
Reading receipt
- The LiteRT Tensor API allows native C++ control over model graphs for edge devices.
- It supports running the same graph on CPU, GPU and NPU without rewriting code.
- A demo app uses SAM 2 on WebGPU, achieving over 30 frames per second.