Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ Please follow the steps described below to setup development environment.
- Node.js (20.0+): https://nodejs.org/ - (Optional) Use nvm ([Windows](https://github.com/coreybutler/nvm-windows) / [Mac/Linux](https://github.com/creationix/nvm)) to install Node.js

- Python (3.9+): https://www.python.org/downloads/

- python should be added to the PATH environment variable

- Visual Studio Code: https://code.visualstudio.com/

- **required** extension: [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- **required** extension: [Prettier](https://marketplace.visualstudio.com/items?itemName=SimonSiefke.prettier-vscode)
- **required** extension: [JavaScript Debugger](https://marketplace.visualstudio.com/items?itemName=ms-vscode.js-debug-nightly)
Expand Down Expand Up @@ -294,13 +292,11 @@ From ORT v1.19 onwards, the ONNX Runtime Mobile packages are no longer published
### Build

1. Install NPM packages for ONNX Runtime common JavaScript library and required React Native JavaScript libraries

- in `<ORT_ROOT>/js/`, run `npm ci`.
- in `<ORT_ROOT>/js/common/`, run `npm ci`.
- in `<ORT_ROOT>/js/react_native/`, run `yarn`.

2. Acquire or build the Android ONNX Runtime package

1. To use a published Android ONNX Runtime package from Maven, go to step 5.

2. Set up an Android build environment using these [instructions](https://onnxruntime.ai/docs/build/android.html). Note that the dependencies are quite convoluted, so using the specified JDK and Gradle versions is important.
Expand All @@ -326,7 +322,6 @@ From ORT v1.19 onwards, the ONNX Runtime Mobile packages are no longer published
```

3. Build iOS ONNX Runtime package

1. To use the published C/C++ ONNX Runtime package from CocoaPods, skip all steps below.

2. Set up iOS build environment using these [instructions](https://onnxruntime.ai/docs/build/ios.html).
Expand Down Expand Up @@ -371,7 +366,6 @@ From ORT v1.19 onwards, the ONNX Runtime Mobile packages are no longer published
- Run E2E Testing with Detox framework

When testing with integrated [Detox](https://wix.github.io/Detox/docs/next/introduction/getting-started) framework for Android and iOS e2e apps:

- Detox prerequisites:

Install detox command line tools:
Expand All @@ -388,7 +382,6 @@ From ORT v1.19 onwards, the ONNX Runtime Mobile packages are no longer published
```

Main Detox project files:

- `.detoxrc.js` -Detox config file;
- `e2e/jest.config.js` -Jest configuration;
- `e2e/OnnxruntimeModuleExample.test.js` - initial react native onnxruntimemodule e2e detox test.
Expand Down
2 changes: 1 addition & 1 deletion js/common/lib/env-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type LogLevelType = Env['logLevel'];
let logLevelValue: Required<LogLevelType> = 'warning';

export const env: Env = {
wasm: {} as Env.WebAssemblyFlags,
wasm: {},
webgl: {} as Env.WebGLFlags,
webgpu: {} as Env.WebGpuFlags,
versions: { common: version },
Expand Down
3 changes: 2 additions & 1 deletion js/common/lib/inference-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ export declare namespace InferenceSession {
* @see https://www.w3.org/TR/webnn/#dom-ml-createcontext
*/
export interface WebNNOptionsWithMLContext
extends WebNNExecutionProviderName,
extends
WebNNExecutionProviderName,
Omit<WebNNContextOptions, 'deviceType'>,
Required<Pick<WebNNContextOptions, 'deviceType'>> {
context: TryGetGlobalType<'MLContext'>;
Expand Down
6 changes: 1 addition & 5 deletions js/common/lib/tensor-factory-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ import { Tensor } from './tensor-impl.js';
import { Tensor as TensorInterface } from './tensor.js';

interface BufferToTensorOptions
extends OptionsDimensions,
OptionsTensorLayout,
OptionsNormalizationParameters,
OptionsFormat,
OptionsTensorFormat {}
extends OptionsDimensions, OptionsTensorLayout, OptionsNormalizationParameters, OptionsFormat, OptionsTensorFormat {}

/**
* Create a new tensor object from image object
Expand Down
36 changes: 17 additions & 19 deletions js/common/lib/tensor-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ interface GpuResourceConstructorParameters<T extends Tensor.Type> {
/**
* represent the parameter for constructing a tensor from a pinned CPU buffer
*/
export interface CpuPinnedConstructorParameters<T extends Tensor.CpuPinnedDataTypes = Tensor.CpuPinnedDataTypes>
extends CommonConstructorParameters<T> {
export interface CpuPinnedConstructorParameters<
T extends Tensor.CpuPinnedDataTypes = Tensor.CpuPinnedDataTypes,
> extends CommonConstructorParameters<T> {
/**
* Specify the location of the data to be 'cpu-pinned'.
*/
Expand All @@ -58,8 +59,7 @@ export interface CpuPinnedConstructorParameters<T extends Tensor.CpuPinnedDataTy
* represent the parameter for constructing a tensor from a WebGL texture
*/
export interface TextureConstructorParameters<T extends Tensor.TextureDataTypes = Tensor.TextureDataTypes>
extends CommonConstructorParameters<T>,
GpuResourceConstructorParameters<T> {
extends CommonConstructorParameters<T>, GpuResourceConstructorParameters<T> {
/**
* Specify the location of the data to be 'texture'.
*/
Expand All @@ -74,8 +74,7 @@ export interface TextureConstructorParameters<T extends Tensor.TextureDataTypes
* represent the parameter for constructing a tensor from a WebGPU buffer
*/
export interface GpuBufferConstructorParameters<T extends Tensor.GpuBufferDataTypes = Tensor.GpuBufferDataTypes>
extends CommonConstructorParameters<T>,
GpuResourceConstructorParameters<T> {
extends CommonConstructorParameters<T>, GpuResourceConstructorParameters<T> {
/**
* Specify the location of the data to be 'gpu-buffer'.
*/
Expand All @@ -87,8 +86,7 @@ export interface GpuBufferConstructorParameters<T extends Tensor.GpuBufferDataTy
}

export interface MLTensorConstructorParameters<T extends Tensor.MLTensorDataTypes = Tensor.MLTensorDataTypes>
extends CommonConstructorParameters<T>,
GpuResourceConstructorParameters<T> {
extends CommonConstructorParameters<T>, GpuResourceConstructorParameters<T> {
/**
* Specify the location of the data to be 'ml-tensor'.
*/
Expand Down Expand Up @@ -191,51 +189,51 @@ export interface OptionsNormalizationParameters {
// #region Options composition

export interface TensorFromImageDataOptions
extends OptionResizedDimensions,
extends
OptionResizedDimensions,
OptionsTensorFormat,
OptionsTensorLayout,
OptionsTensorDataType,
OptionsNormalizationParameters {}

export interface TensorFromImageElementOptions
extends OptionResizedDimensions,
extends
OptionResizedDimensions,
OptionsTensorFormat,
OptionsTensorLayout,
OptionsTensorDataType,
OptionsNormalizationParameters {}

export interface TensorFromUrlOptions
extends OptionsDimensions,
extends
OptionsDimensions,
OptionResizedDimensions,
OptionsTensorFormat,
OptionsTensorLayout,
OptionsTensorDataType,
OptionsNormalizationParameters {}

export interface TensorFromImageBitmapOptions
extends OptionResizedDimensions,
extends
OptionResizedDimensions,
OptionsTensorFormat,
OptionsTensorLayout,
OptionsTensorDataType,
OptionsNormalizationParameters {}

export interface TensorFromTextureOptions<T extends Tensor.TextureDataTypes>
extends Required<OptionsDimensions>,
OptionsFormat,
GpuResourceConstructorParameters<T> /* TODO: add more */ {}
extends Required<OptionsDimensions>, OptionsFormat, GpuResourceConstructorParameters<T> /* TODO: add more */ {}

export interface TensorFromGpuBufferOptions<T extends Tensor.GpuBufferDataTypes>
extends Pick<Tensor, 'dims'>,
GpuResourceConstructorParameters<T> {
extends Pick<Tensor, 'dims'>, GpuResourceConstructorParameters<T> {
/**
* Describes the data type of the tensor.
*/
dataType?: T;
}

export interface TensorFromMLTensorOptions<T extends Tensor.MLTensorDataTypes>
extends Pick<Tensor, 'dims'>,
GpuResourceConstructorParameters<T> {
extends Pick<Tensor, 'dims'>, GpuResourceConstructorParameters<T> {
/**
* Describes the data type of the tensor.
*/
Expand Down
12 changes: 6 additions & 6 deletions js/common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion js/node/lib/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ class OnnxruntimeSessionHandler implements InferenceSessionHandler {
if (typeof pathOrBuffer === 'string') {
this.#inferenceSession.loadModel(pathOrBuffer, options);
} else {
this.#inferenceSession.loadModel(pathOrBuffer.buffer, pathOrBuffer.byteOffset, pathOrBuffer.byteLength, options);
this.#inferenceSession.loadModel(
pathOrBuffer.buffer as ArrayBuffer,
pathOrBuffer.byteOffset,
pathOrBuffer.byteLength,
options,
);
}

// prepare input/output names and metadata
Expand Down
Loading
Loading