onnxruntime-node 1.11.0 → 1.12.0-dev.20220429-49d7050b8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -29
- package/__commit.txt +1 -0
- package/bin/napi-v3/darwin/arm64/{libonnxruntime.1.11.0.dylib → libonnxruntime.1.12.0.dylib} +0 -0
- package/bin/napi-v3/darwin/arm64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/darwin/x64/{libonnxruntime.1.11.0.dylib → libonnxruntime.1.12.0.dylib} +0 -0
- package/bin/napi-v3/darwin/x64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/linux/arm64/{libonnxruntime.so.1.11.0 → libonnxruntime.so.1.12.0} +0 -0
- package/bin/napi-v3/linux/arm64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/linux/x64/{libonnxruntime.so.1.11.0 → libonnxruntime.so.1.12.0} +0 -0
- package/bin/napi-v3/linux/x64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/win32/arm64/onnxruntime.dll +0 -0
- package/bin/napi-v3/win32/arm64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/win32/arm64/onnxruntime_providers_shared.dll +0 -0
- package/bin/napi-v3/win32/x64/onnxruntime.dll +0 -0
- package/bin/napi-v3/win32/x64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/win32/x64/onnxruntime_providers_shared.dll +0 -0
- package/lib/backend.ts +70 -70
- package/lib/binding.ts +43 -43
- package/lib/index.ts +8 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# ONNX Runtime Node.js Binding
|
|
2
|
-
|
|
3
|
-
ONNX Runtime Node.js binding enables Node.js applications to run ONNX model inference.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
Install the latest stable version:
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
npm install onnxruntime-node
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Refer to [ONNX Runtime JavaScript examples](https://github.com/microsoft/onnxruntime-inference-examples/tree/main/js) for samples and tutorials.
|
|
14
|
-
|
|
15
|
-
## Requirements
|
|
16
|
-
|
|
17
|
-
ONNXRuntime works on Node.js v12.x+ or Electron v5.x+.
|
|
18
|
-
|
|
19
|
-
Following platforms are supported with pre-built binaries:
|
|
20
|
-
|
|
21
|
-
- Windows x64 CPU NAPI_v3
|
|
22
|
-
- Linux x64 CPU NAPI_v3
|
|
23
|
-
- MacOS x64 CPU NAPI_v3
|
|
24
|
-
|
|
25
|
-
To use on platforms without pre-built binaries, you can build Node.js binding from source and consume it by `npm install <onnxruntime_repo_root>/js/node/`. See also [instructions](https://www.onnxruntime.ai/docs/how-to/build.html#apis-and-language-bindings) for building ONNX Runtime Node.js binding locally.
|
|
26
|
-
|
|
27
|
-
## License
|
|
28
|
-
|
|
29
|
-
License information can be found [here](https://github.com/microsoft/onnxruntime/blob/master/README.md#license).
|
|
1
|
+
# ONNX Runtime Node.js Binding
|
|
2
|
+
|
|
3
|
+
ONNX Runtime Node.js binding enables Node.js applications to run ONNX model inference.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Install the latest stable version:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install onnxruntime-node
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Refer to [ONNX Runtime JavaScript examples](https://github.com/microsoft/onnxruntime-inference-examples/tree/main/js) for samples and tutorials.
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
ONNXRuntime works on Node.js v12.x+ or Electron v5.x+.
|
|
18
|
+
|
|
19
|
+
Following platforms are supported with pre-built binaries:
|
|
20
|
+
|
|
21
|
+
- Windows x64 CPU NAPI_v3
|
|
22
|
+
- Linux x64 CPU NAPI_v3
|
|
23
|
+
- MacOS x64 CPU NAPI_v3
|
|
24
|
+
|
|
25
|
+
To use on platforms without pre-built binaries, you can build Node.js binding from source and consume it by `npm install <onnxruntime_repo_root>/js/node/`. See also [instructions](https://www.onnxruntime.ai/docs/how-to/build.html#apis-and-language-bindings) for building ONNX Runtime Node.js binding locally.
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
License information can be found [here](https://github.com/microsoft/onnxruntime/blob/master/README.md#license).
|
package/__commit.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
49d7050b88338dd57839159aa4ce8fb0c199b064
|
package/bin/napi-v3/darwin/arm64/{libonnxruntime.1.11.0.dylib → libonnxruntime.1.12.0.dylib}
RENAMED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/backend.ts
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import {Backend, InferenceSession, SessionHandler} from 'onnxruntime-common';
|
|
5
|
-
import {Binding, binding} from './binding';
|
|
6
|
-
|
|
7
|
-
class OnnxruntimeSessionHandler implements SessionHandler {
|
|
8
|
-
#inferenceSession: Binding.InferenceSession;
|
|
9
|
-
|
|
10
|
-
constructor(pathOrBuffer: string|Uint8Array, options: InferenceSession.SessionOptions) {
|
|
11
|
-
this.#inferenceSession = new binding.InferenceSession();
|
|
12
|
-
if (typeof pathOrBuffer === 'string') {
|
|
13
|
-
this.#inferenceSession.loadModel(pathOrBuffer, options);
|
|
14
|
-
} else {
|
|
15
|
-
this.#inferenceSession.loadModel(pathOrBuffer.buffer, pathOrBuffer.byteOffset, pathOrBuffer.byteLength, options);
|
|
16
|
-
}
|
|
17
|
-
this.inputNames = this.#inferenceSession.inputNames;
|
|
18
|
-
this.outputNames = this.#inferenceSession.outputNames;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async dispose(): Promise<void> {
|
|
22
|
-
return Promise.resolve();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
readonly inputNames: string[];
|
|
26
|
-
readonly outputNames: string[];
|
|
27
|
-
|
|
28
|
-
startProfiling(): void {
|
|
29
|
-
// TODO: implement profiling
|
|
30
|
-
}
|
|
31
|
-
endProfiling(): void {
|
|
32
|
-
// TODO: implement profiling
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async run(feeds: SessionHandler.FeedsType, fetches: SessionHandler.FetchesType, options: InferenceSession.RunOptions):
|
|
36
|
-
Promise<SessionHandler.ReturnType> {
|
|
37
|
-
return new Promise((resolve, reject) => {
|
|
38
|
-
process.nextTick(() => {
|
|
39
|
-
try {
|
|
40
|
-
resolve(this.#inferenceSession.run(feeds, fetches, options));
|
|
41
|
-
} catch (e) {
|
|
42
|
-
// reject if any error is thrown
|
|
43
|
-
reject(e);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class OnnxruntimeBackend implements Backend {
|
|
51
|
-
async init(): Promise<void> {
|
|
52
|
-
return Promise.resolve();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async createSessionHandler(pathOrBuffer: string|Uint8Array, options?: InferenceSession.SessionOptions):
|
|
56
|
-
Promise<SessionHandler> {
|
|
57
|
-
return new Promise((resolve, reject) => {
|
|
58
|
-
process.nextTick(() => {
|
|
59
|
-
try {
|
|
60
|
-
resolve(new OnnxruntimeSessionHandler(pathOrBuffer, options || {}));
|
|
61
|
-
} catch (e) {
|
|
62
|
-
// reject if any error is thrown
|
|
63
|
-
reject(e);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const onnxruntimeBackend = new OnnxruntimeBackend();
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import {Backend, InferenceSession, SessionHandler} from 'onnxruntime-common';
|
|
5
|
+
import {Binding, binding} from './binding';
|
|
6
|
+
|
|
7
|
+
class OnnxruntimeSessionHandler implements SessionHandler {
|
|
8
|
+
#inferenceSession: Binding.InferenceSession;
|
|
9
|
+
|
|
10
|
+
constructor(pathOrBuffer: string|Uint8Array, options: InferenceSession.SessionOptions) {
|
|
11
|
+
this.#inferenceSession = new binding.InferenceSession();
|
|
12
|
+
if (typeof pathOrBuffer === 'string') {
|
|
13
|
+
this.#inferenceSession.loadModel(pathOrBuffer, options);
|
|
14
|
+
} else {
|
|
15
|
+
this.#inferenceSession.loadModel(pathOrBuffer.buffer, pathOrBuffer.byteOffset, pathOrBuffer.byteLength, options);
|
|
16
|
+
}
|
|
17
|
+
this.inputNames = this.#inferenceSession.inputNames;
|
|
18
|
+
this.outputNames = this.#inferenceSession.outputNames;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async dispose(): Promise<void> {
|
|
22
|
+
return Promise.resolve();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
readonly inputNames: string[];
|
|
26
|
+
readonly outputNames: string[];
|
|
27
|
+
|
|
28
|
+
startProfiling(): void {
|
|
29
|
+
// TODO: implement profiling
|
|
30
|
+
}
|
|
31
|
+
endProfiling(): void {
|
|
32
|
+
// TODO: implement profiling
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async run(feeds: SessionHandler.FeedsType, fetches: SessionHandler.FetchesType, options: InferenceSession.RunOptions):
|
|
36
|
+
Promise<SessionHandler.ReturnType> {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
process.nextTick(() => {
|
|
39
|
+
try {
|
|
40
|
+
resolve(this.#inferenceSession.run(feeds, fetches, options));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
// reject if any error is thrown
|
|
43
|
+
reject(e);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
class OnnxruntimeBackend implements Backend {
|
|
51
|
+
async init(): Promise<void> {
|
|
52
|
+
return Promise.resolve();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async createSessionHandler(pathOrBuffer: string|Uint8Array, options?: InferenceSession.SessionOptions):
|
|
56
|
+
Promise<SessionHandler> {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
process.nextTick(() => {
|
|
59
|
+
try {
|
|
60
|
+
resolve(new OnnxruntimeSessionHandler(pathOrBuffer, options || {}));
|
|
61
|
+
} catch (e) {
|
|
62
|
+
// reject if any error is thrown
|
|
63
|
+
reject(e);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const onnxruntimeBackend = new OnnxruntimeBackend();
|
package/lib/binding.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import {InferenceSession, OnnxValue} from 'onnxruntime-common';
|
|
5
|
-
|
|
6
|
-
type SessionOptions = InferenceSession.SessionOptions;
|
|
7
|
-
type FeedsType = {
|
|
8
|
-
[name: string]: OnnxValue;
|
|
9
|
-
};
|
|
10
|
-
type FetchesType = {
|
|
11
|
-
[name: string]: OnnxValue|null;
|
|
12
|
-
};
|
|
13
|
-
type ReturnType = {
|
|
14
|
-
[name: string]: OnnxValue;
|
|
15
|
-
};
|
|
16
|
-
type RunOptions = InferenceSession.RunOptions;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Binding exports a simple synchronized inference session object wrap.
|
|
21
|
-
*/
|
|
22
|
-
export declare namespace Binding {
|
|
23
|
-
export interface InferenceSession {
|
|
24
|
-
loadModel(modelPath: string, options: SessionOptions): void;
|
|
25
|
-
loadModel(buffer: ArrayBuffer, byteOffset: number, byteLength: number, options: SessionOptions): void;
|
|
26
|
-
|
|
27
|
-
readonly inputNames: string[];
|
|
28
|
-
readonly outputNames: string[];
|
|
29
|
-
|
|
30
|
-
run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface InferenceSessionConstructor {
|
|
34
|
-
new(): InferenceSession;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// export native binding
|
|
39
|
-
export const binding =
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
41
|
-
require(`../bin/napi-v3/${process.platform}/${process.arch}/onnxruntime_binding.node`) as
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
43
|
-
{InferenceSession: Binding.InferenceSessionConstructor};
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import {InferenceSession, OnnxValue} from 'onnxruntime-common';
|
|
5
|
+
|
|
6
|
+
type SessionOptions = InferenceSession.SessionOptions;
|
|
7
|
+
type FeedsType = {
|
|
8
|
+
[name: string]: OnnxValue;
|
|
9
|
+
};
|
|
10
|
+
type FetchesType = {
|
|
11
|
+
[name: string]: OnnxValue|null;
|
|
12
|
+
};
|
|
13
|
+
type ReturnType = {
|
|
14
|
+
[name: string]: OnnxValue;
|
|
15
|
+
};
|
|
16
|
+
type RunOptions = InferenceSession.RunOptions;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Binding exports a simple synchronized inference session object wrap.
|
|
21
|
+
*/
|
|
22
|
+
export declare namespace Binding {
|
|
23
|
+
export interface InferenceSession {
|
|
24
|
+
loadModel(modelPath: string, options: SessionOptions): void;
|
|
25
|
+
loadModel(buffer: ArrayBuffer, byteOffset: number, byteLength: number, options: SessionOptions): void;
|
|
26
|
+
|
|
27
|
+
readonly inputNames: string[];
|
|
28
|
+
readonly outputNames: string[];
|
|
29
|
+
|
|
30
|
+
run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface InferenceSessionConstructor {
|
|
34
|
+
new(): InferenceSession;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// export native binding
|
|
39
|
+
export const binding =
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
41
|
+
require(`../bin/napi-v3/${process.platform}/${process.arch}/onnxruntime_binding.node`) as
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
43
|
+
{InferenceSession: Binding.InferenceSessionConstructor};
|
package/lib/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
export * from 'onnxruntime-common';
|
|
5
|
-
import {registerBackend} from 'onnxruntime-common';
|
|
6
|
-
import {onnxruntimeBackend} from './backend';
|
|
7
|
-
|
|
8
|
-
registerBackend('cpu', onnxruntimeBackend, 1);
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
export * from 'onnxruntime-common';
|
|
5
|
+
import {registerBackend} from 'onnxruntime-common';
|
|
6
|
+
import {onnxruntimeBackend} from './backend';
|
|
7
|
+
|
|
8
|
+
registerBackend('cpu', onnxruntimeBackend, 1);
|
package/package.json
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
3
|
|
14
14
|
]
|
|
15
15
|
},
|
|
16
|
-
"version": "1.
|
|
16
|
+
"version": "1.12.0-dev.20220429-49d7050b8",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"onnxruntime-common": "~1.
|
|
18
|
+
"onnxruntime-common": "~1.12.0-dev.20220429-49d7050b8"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"buildr": "tsc && node ./script/build --config=RelWithDebInfo",
|