Skip to content

Latest commit

 

History

History
124 lines (85 loc) · 4.6 KB

README.md

File metadata and controls

124 lines (85 loc) · 4.6 KB

node-executorch

node-executorch: Node.js binding for ExecuTorch

Install

npm install node-executorch

Usage

import { Module, Tensor } from 'node-executorch';

const model = await Module.load('path/to/model.pte');

const input = new Tensor('int32', [1, 1], Int32Array.from([ 1 ]));

const outputs = await model.forward([input]);

// Manually release
input.dispose();
model.dispose();

Building node-executorch

Building node-executorch requires a supported version of Node and Rust.

To run the build, run:

$ EXECUTORCH_INSTALL_PREFIX=path/to/executorch/cmake-out yarn build

This command uses the @neon-rs/cli utility to assemble the binary Node addon from the output of cargo.

Available Scripts

In the project directory, you can run:

yarn install

Installs the project, including running yarn build.

yarn build

Builds the Node addon (bin/<platform>/<arch>/executorch.node) from source, generating a release build with cargo --release.

Additional cargo build arguments may be passed to npm run build and similar commands. For example, to enable a cargo feature:

yarn build --feature=beetle

yarn debug

Similar to yarn build but generates a debug build with cargo.

yarn cross

Similar to yarn build but uses cross-rs to cross-compile for another platform. Use the CARGO_BUILD_TARGET environment variable to select the build target.

yarn test

Runs the unit tests by calling cargo test. You can learn more about adding tests to your Rust code from the Rust book.

Project Layout

The directory structure of this project is:

node-executorch/
├── Cargo.toml
├── README.md
├── src/
|   └── lib.rs
├── lib/
|   ├── index.ts
|   └── binding.ts
├── bin/
|   └── <platform>/<arch>/executorch.node
├── scripts/
|   └── postneon-dist.js
├── package.json
└── target/
Entry Purpose
Cargo.toml The Cargo manifest file, which informs the cargo command.
README.md This file.
src/ The directory tree containing the Rust source code for the project.
lib.rs Entry point for the Rust source code.
lib/ The directory tree containing the TypeScript source code for the project.
executorch.node Node addon generated by the build.
scripts/ Utility scripts for the project.
postneon-dist.js Utility script for post-processing the Neon build.
package.json The npm manifest file, which informs the npm command.
target/ Binary artifacts generated by the Rust build.

Learn More

Learn more about:

License

BSD


Built and maintained by BRICKS.