onnxruntime-node 1.11.0 → 1.12.0-dev.20220510-3437967e6

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 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
+ 3437967e63f1cae12613b187c0a71687d08b0042
@@ -1 +1 @@
1
- {"version":3,"file":"backend.js","sourceRoot":"","sources":["../lib/backend.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;;AAGlC,uCAA2C;AAE3C,MAAM,yBAAyB;IAG7B,YAAY,YAA+B,EAAE,OAAwC;QAFrF,oCAA4C;QAG1C,uBAAA,IAAI,qBAAqB,IAAI,iBAAO,CAAC,gBAAgB,EAAE,EAAC;QACxD,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;YACpC,gDAAuB,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;SACzD;aAAM;YACL,gDAAuB,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;SAClH;QACD,IAAI,CAAC,UAAU,GAAG,gDAAuB,UAAU,CAAC;QACpD,IAAI,CAAC,WAAW,GAAG,gDAAuB,WAAW,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,OAAO;QACX,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAKD,cAAc;QACZ,4BAA4B;IAC9B,CAAC;IACD,YAAY;QACV,4BAA4B;IAC9B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAA+B,EAAE,OAAmC,EAAE,OAAoC;QAElH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE;gBACpB,IAAI;oBACF,OA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C;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAEY,QAAA,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
package/lib/backend.ts CHANGED
@@ -1,70 +1,71 @@
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
+
6
+ import {Binding, binding} from './binding';
7
+
8
+ class OnnxruntimeSessionHandler implements SessionHandler {
9
+ #inferenceSession: Binding.InferenceSession;
10
+
11
+ constructor(pathOrBuffer: string|Uint8Array, options: InferenceSession.SessionOptions) {
12
+ this.#inferenceSession = new binding.InferenceSession();
13
+ if (typeof pathOrBuffer === 'string') {
14
+ this.#inferenceSession.loadModel(pathOrBuffer, options);
15
+ } else {
16
+ this.#inferenceSession.loadModel(pathOrBuffer.buffer, pathOrBuffer.byteOffset, pathOrBuffer.byteLength, options);
17
+ }
18
+ this.inputNames = this.#inferenceSession.inputNames;
19
+ this.outputNames = this.#inferenceSession.outputNames;
20
+ }
21
+
22
+ async dispose(): Promise<void> {
23
+ return Promise.resolve();
24
+ }
25
+
26
+ readonly inputNames: string[];
27
+ readonly outputNames: string[];
28
+
29
+ startProfiling(): void {
30
+ // TODO: implement profiling
31
+ }
32
+ endProfiling(): void {
33
+ // TODO: implement profiling
34
+ }
35
+
36
+ async run(feeds: SessionHandler.FeedsType, fetches: SessionHandler.FetchesType, options: InferenceSession.RunOptions):
37
+ Promise<SessionHandler.ReturnType> {
38
+ return new Promise((resolve, reject) => {
39
+ process.nextTick(() => {
40
+ try {
41
+ resolve(this.#inferenceSession.run(feeds, fetches, options));
42
+ } catch (e) {
43
+ // reject if any error is thrown
44
+ reject(e);
45
+ }
46
+ });
47
+ });
48
+ }
49
+ }
50
+
51
+ class OnnxruntimeBackend implements Backend {
52
+ async init(): Promise<void> {
53
+ return Promise.resolve();
54
+ }
55
+
56
+ async createSessionHandler(pathOrBuffer: string|Uint8Array, options?: InferenceSession.SessionOptions):
57
+ Promise<SessionHandler> {
58
+ return new Promise((resolve, reject) => {
59
+ process.nextTick(() => {
60
+ try {
61
+ resolve(new OnnxruntimeSessionHandler(pathOrBuffer, options || {}));
62
+ } catch (e) {
63
+ // reject if any error is thrown
64
+ reject(e);
65
+ }
66
+ });
67
+ });
68
+ }
69
+ }
70
+
71
+ 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.11.0",
16
+ "version": "1.12.0-dev.20220510-3437967e6",
17
17
  "dependencies": {
18
- "onnxruntime-common": "~1.11.0"
18
+ "onnxruntime-common": "~1.12.0-dev.20220505-084165c74"
19
19
  },
20
20
  "scripts": {
21
21
  "buildr": "tsc && node ./script/build --config=RelWithDebInfo",