Skip to main content
Version: 0.7.x

Class: ExecutorchModule

Defined in: packages/react-native-executorch/src/modules/general/ExecutorchModule.ts:13

General module for executing custom Executorch models.

Extends​

  • BaseModule

Constructors​

Constructor​

new ExecutorchModule(): ExecutorchModule

Returns​

ExecutorchModule

Inherited from​

BaseModule.constructor

Properties​

nativeModule​

nativeModule: any = null

Defined in: packages/react-native-executorch/src/modules/BaseModule.ts:8

Native module instance

Inherited from​

BaseModule.nativeModule

Methods​

delete()​

delete(): void

Defined in: packages/react-native-executorch/src/modules/BaseModule.ts:41

Unloads the model from memory.

Returns​

void

Inherited from​

BaseModule.delete


forward()​

forward(inputTensor): Promise<TensorPtr[]>

Defined in: packages/react-native-executorch/src/modules/general/ExecutorchModule.ts:45

Executes the model's forward pass, where input is an array of TensorPtr objects. If the inference is successful, an array of tensor pointers is returned.

Parameters​

inputTensor​

TensorPtr[]

Array of input tensor pointers.

Returns​

Promise<TensorPtr[]>

An array of output tensor pointers.


forwardET()​

protected forwardET(inputTensor): Promise<TensorPtr[]>

Defined in: packages/react-native-executorch/src/modules/BaseModule.ts:23

Runs the model's forward method with the given input tensors. It returns the output tensors that mimic the structure of output from ExecuTorch.

Parameters​

inputTensor​

TensorPtr[]

Array of input tensors.

Returns​

Promise<TensorPtr[]>

Array of output tensors.

Inherited from​

BaseModule.forwardET


getInputShape()​

getInputShape(methodName, index): Promise<number[]>

Defined in: packages/react-native-executorch/src/modules/BaseModule.ts:34

Gets the input shape for a given method and index.

Parameters​

methodName​

string

method name

index​

number

index of the argument which shape is requested

Returns​

Promise<number[]>

The input shape as an array of numbers.

Inherited from​

BaseModule.getInputShape


load()​

load(modelSource, onDownloadProgressCallback): Promise<void>

Defined in: packages/react-native-executorch/src/modules/general/ExecutorchModule.ts:21

Loads the model, where modelSource is a string, number, or object that specifies the location of the model binary. Optionally accepts a download progress callback.

Parameters​

modelSource​

ResourceSource

Source of the model to be loaded.

onDownloadProgressCallback​

(progress) => void

Optional callback to monitor download progress.

Returns​

Promise<void>

Overrides​

BaseModule.load