
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@litertjs/core
Advanced tools
Core web runtime for LiteRT (previously TFLite), Google's open-source high performance runtime for on-device AI.
This package provides the core functionality to load and run arbitrary LiteRT
(.tflite
) models directly in the browser, with support for WebGPU and CPU
acceleration.
This is the primary package for LiteRT.js. For integration with TensorFlow.js,
see
@litertjs/tfjs-interop
.
To test and benchmark your models, check out the
@litertjs/model-tester
.
@litertjs/tfjs-interop
package for details.For a complete guide, see our docs at ai.google.dev/edge/litert/web.
The following code snippet loads LiteRT.js, loads a MobileNetV2 model, and runs it on a sample input tensor.
import {loadLiteRt, loadAndCompile, Tensor} from '@litertjs/core';
// Initialize LiteRT.js's Wasm files.
// These files are located in `node_modules/@litertjs/core/wasm/`
// and need to be served by your web server.
await loadLiteRt('/path/to/wasm/directory/');
const model = await loadAndCompile(
'/path/to/your/model/torchvision_mobilenet_v2.tflite',
{accelerator: 'webgpu'},
);
// Create an input tensor.
const inputTypedArray = new Float32Array(1 * 3 * 224 * 224);
const inputTensor = new Tensor(inputTypedArray, [1, 3, 224, 224]);
// Move the tensor to the GPU for a WebGPU-accelerated model.
const gpuTensor = await inputTensor.moveTo('webgpu');
// Run the model.
const results = model.run(gpuTensor);
// All tensors that are not moved to another backend with `moveTo` must
// eventually be freed with `.delete()`.
gpuTensor.delete();
// Move the result back to the CPU to read the data.
const result = results[0].moveTo('wasm');
console.log(result.toTypedArray());
// Clean up the result tensor.
result.delete();
FAQs
LiteRT.js package
The npm package @litertjs/core receives a total of 30 weekly downloads. As such, @litertjs/core popularity was classified as not popular.
We found that @litertjs/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.