onnxruntime-node 1.16.3 → 1.17.0-dev.20240117-81d363045b

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
@@ -22,7 +22,11 @@ Following platforms are supported with pre-built binaries:
22
22
  - Linux x64 CPU NAPI_v3
23
23
  - MacOS x64 CPU NAPI_v3
24
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.
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://onnxruntime.ai/docs/build/inferencing.html#apis-and-language-bindings) for building ONNX Runtime Node.js binding locally.
26
+
27
+ # GPU Support
28
+
29
+ Right now, the Windows version supports only the DML provider. Linux x64 can use CUDA and TensorRT.
26
30
 
27
31
  ## License
28
32
 
package/__commit.txt ADDED
@@ -0,0 +1 @@
1
+ 81d363045ba273b16a3ec654c53a15217a2d2a36
package/dist/backend.js CHANGED
@@ -14,7 +14,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
14
14
  };
15
15
  var _OnnxruntimeSessionHandler_inferenceSession;
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.onnxruntimeBackend = void 0;
17
+ exports.listSupportedBackends = exports.onnxruntimeBackend = void 0;
18
18
  const binding_1 = require("./binding");
19
19
  class OnnxruntimeSessionHandler {
20
20
  constructor(pathOrBuffer, options) {
@@ -30,7 +30,7 @@ class OnnxruntimeSessionHandler {
30
30
  this.outputNames = __classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").outputNames;
31
31
  }
32
32
  async dispose() {
33
- return Promise.resolve();
33
+ __classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").dispose();
34
34
  }
35
35
  startProfiling() {
36
36
  // TODO: implement profiling
@@ -57,7 +57,7 @@ class OnnxruntimeBackend {
57
57
  async init() {
58
58
  return Promise.resolve();
59
59
  }
60
- async createSessionHandler(pathOrBuffer, options) {
60
+ async createInferenceSessionHandler(pathOrBuffer, options) {
61
61
  return new Promise((resolve, reject) => {
62
62
  process.nextTick(() => {
63
63
  try {
@@ -72,4 +72,5 @@ class OnnxruntimeBackend {
72
72
  }
73
73
  }
74
74
  exports.onnxruntimeBackend = new OnnxruntimeBackend();
75
+ exports.listSupportedBackends = binding_1.binding.listSupportedBackends;
75
76
  //# sourceMappingURL=backend.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"backend.js","sourceRoot":"","sources":["../lib/backend.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;AAIlC,uCAA2C;AAE3C,MAAM,yBAAyB;IAG7B,YAAY,YAA+B,EAAE,OAAwC;QAFrF,8DAA4C;QAG1C,uBAAA,IAAI,+CAAqB,IAAI,iBAAO,CAAC,gBAAgB,EAAE,MAAA,CAAC;QACxD,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;YACpC,uBAAA,IAAI,mDAAkB,CAAC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;SACzD;aAAM;YACL,uBAAA,IAAI,mDAAkB,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;SAClH;QACD,IAAI,CAAC,UAAU,GAAG,uBAAA,IAAI,mDAAkB,CAAC,UAAU,CAAC;QACpD,IAAI,CAAC,WAAW,GAAG,uBAAA,IAAI,mDAAkB,CAAC,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;IA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AE,OAAyC;QAE5G,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE;gBACpB,IAAI;oBACF,OAAO,CAAC,IAAI,yBAAyB,CAAC,YAAY,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;iBACrE;gBAAC,OAAO,CAAC,EAAE;oBACV,gCAAgC;oBAChC,MAAM,CAAC,CAAC,CAAC,CAAC;iBACX;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAEY,QAAA,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;AAC9C,QAAA,qBAAqB,GAAG,iBAAO,CAAC,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAoClC,wBAAwB;AACX,QAAA,OAAO;AAChB,qGAAqG;AACrG,OAAO,CAAC,kBAAkB,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,2BAA2B,CAE9B,CAAC"}
1
+ {"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AA2ClC,wBAAwB;AACX,QAAA,OAAO;AAChB,qGAAqG;AACrG,OAAO,CAAC,kBAAkB,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,2BAA2B,CAIxF,CAAC"}
package/dist/index.js CHANGED
@@ -16,10 +16,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.listSupportedBackends = void 0;
19
20
  __exportStar(require("onnxruntime-common"), exports);
21
+ var backend_1 = require("./backend");
22
+ Object.defineProperty(exports, "listSupportedBackends", { enumerable: true, get: function () { return backend_1.listSupportedBackends; } });
20
23
  const onnxruntime_common_1 = require("onnxruntime-common");
21
- const backend_1 = require("./backend");
22
24
  const version_1 = require("./version");
23
- (0, onnxruntime_common_1.registerBackend)('cpu', backend_1.onnxruntimeBackend, 100);
24
- onnxruntime_common_1.env.versions.node = version_1.version;
25
+ const backend_2 = require("./backend");
26
+ const backends = (0, backend_2.listSupportedBackends)();
27
+ for (const backend of backends) {
28
+ (0, onnxruntime_common_1.registerBackend)(backend.name, backend_2.onnxruntimeBackend, 100);
29
+ }
30
+ Object.defineProperty(onnxruntime_common_1.env.versions, 'node', { value: version_1.version, enumerable: true });
25
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;AAElC,qDAAmC;AACnC,2DAAwD;AACxD,uCAA6C;AAC7C,uCAAkC;AAElC,IAAA,oCAAe,EAAC,KAAK,EAAE,4BAAkB,EAAE,GAAG,CAAC,CAAC;AAEhD,wBAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,iBAAO,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;;AAElC,qDAAmC;AACnC,qCAAgD;AAAxC,gHAAA,qBAAqB,OAAA;AAC7B,2DAAwD;AACxD,uCAAkC;AAClC,uCAAoE;AAEpE,MAAM,QAAQ,GAAG,IAAA,+BAAqB,GAAE,CAAC;AACzC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;IAC9B,IAAA,oCAAe,EAAC,OAAO,CAAC,IAAI,EAAE,4BAAkB,EAAE,GAAG,CAAC,CAAC;CACxD;AAED,MAAM,CAAC,cAAc,CAAC,wBAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAC,KAAK,EAAE,iBAAO,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC"}
package/dist/version.js CHANGED
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.version = void 0;
6
6
  // This file is generated by /js/scripts/update-version.ts
7
7
  // Do not modify file content manually.
8
- exports.version = '1.16.3';
8
+ exports.version = '1.17.0-dev.20240117-81d363045b';
9
9
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../lib/version.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,0DAA0D;AAC1D,uCAAuC;AAE1B,QAAA,OAAO,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../lib/version.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,0DAA0D;AAC1D,uCAAuC;AAE1B,QAAA,OAAO,GAAG,gCAAgC,CAAC"}
package/lib/backend.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
 
4
- import {Backend, InferenceSession, SessionHandler} from 'onnxruntime-common';
4
+ import {Backend, InferenceSession, InferenceSessionHandler, SessionHandler} from 'onnxruntime-common';
5
5
 
6
6
  import {Binding, binding} from './binding';
7
7
 
8
- class OnnxruntimeSessionHandler implements SessionHandler {
8
+ class OnnxruntimeSessionHandler implements InferenceSessionHandler {
9
9
  #inferenceSession: Binding.InferenceSession;
10
10
 
11
11
  constructor(pathOrBuffer: string|Uint8Array, options: InferenceSession.SessionOptions) {
@@ -20,7 +20,7 @@ class OnnxruntimeSessionHandler implements SessionHandler {
20
20
  }
21
21
 
22
22
  async dispose(): Promise<void> {
23
- return Promise.resolve();
23
+ this.#inferenceSession.dispose();
24
24
  }
25
25
 
26
26
  readonly inputNames: string[];
@@ -53,8 +53,8 @@ class OnnxruntimeBackend implements Backend {
53
53
  return Promise.resolve();
54
54
  }
55
55
 
56
- async createSessionHandler(pathOrBuffer: string|Uint8Array, options?: InferenceSession.SessionOptions):
57
- Promise<SessionHandler> {
56
+ async createInferenceSessionHandler(pathOrBuffer: string|Uint8Array, options?: InferenceSession.SessionOptions):
57
+ Promise<InferenceSessionHandler> {
58
58
  return new Promise((resolve, reject) => {
59
59
  process.nextTick(() => {
60
60
  try {
@@ -69,3 +69,4 @@ class OnnxruntimeBackend implements Backend {
69
69
  }
70
70
 
71
71
  export const onnxruntimeBackend = new OnnxruntimeBackend();
72
+ export const listSupportedBackends = binding.listSupportedBackends;
package/lib/binding.ts CHANGED
@@ -28,16 +28,25 @@ export declare namespace Binding {
28
28
  readonly outputNames: string[];
29
29
 
30
30
  run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
31
+
32
+ dispose(): void;
31
33
  }
32
34
 
33
35
  export interface InferenceSessionConstructor {
34
36
  new(): InferenceSession;
35
37
  }
38
+
39
+ export interface SupportedBackend {
40
+ name: string;
41
+ bundled: boolean;
42
+ }
36
43
  }
37
44
 
38
45
  // export native binding
39
46
  export const binding =
40
47
  // 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};
48
+ require(`../bin/napi-v3/${process.platform}/${process.arch}/onnxruntime_binding.node`) as {
49
+ // eslint-disable-next-line @typescript-eslint/naming-convention
50
+ InferenceSession: Binding.InferenceSessionConstructor;
51
+ listSupportedBackends: () => Binding.SupportedBackend[];
52
+ };
package/lib/index.ts CHANGED
@@ -2,10 +2,14 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  export * from 'onnxruntime-common';
5
+ export {listSupportedBackends} from './backend';
5
6
  import {registerBackend, env} from 'onnxruntime-common';
6
- import {onnxruntimeBackend} from './backend';
7
7
  import {version} from './version';
8
+ import {onnxruntimeBackend, listSupportedBackends} from './backend';
8
9
 
9
- registerBackend('cpu', onnxruntimeBackend, 100);
10
+ const backends = listSupportedBackends();
11
+ for (const backend of backends) {
12
+ registerBackend(backend.name, onnxruntimeBackend, 100);
13
+ }
10
14
 
11
- env.versions.node = version;
15
+ Object.defineProperty(env.versions, 'node', {value: version, enumerable: true});
package/lib/version.ts CHANGED
@@ -4,4 +4,4 @@
4
4
  // This file is generated by /js/scripts/update-version.ts
5
5
  // Do not modify file content manually.
6
6
 
7
- export const version = '1.16.3';
7
+ export const version = '1.17.0-dev.20240117-81d363045b';
package/package.json CHANGED
@@ -13,12 +13,13 @@
13
13
  3
14
14
  ]
15
15
  },
16
- "version": "1.16.3",
16
+ "version": "1.17.0-dev.20240117-81d363045b",
17
17
  "dependencies": {
18
- "onnxruntime-common": "~1.16.3"
18
+ "onnxruntime-common": "1.17.0-dev.20240116-80f274ca6f"
19
19
  },
20
20
  "scripts": {
21
21
  "buildr": "tsc && node ./script/build --config=RelWithDebInfo",
22
+ "preprepare": "node -e \"require('node:fs').copyFileSync('./node_modules/long/index.d.ts', './node_modules/long/umd/index.d.ts')\"",
22
23
  "prepare": "tsc --build script test .",
23
24
  "rebuild": "tsc && node ./script/build --rebuild",
24
25
  "rebuildd": "tsc && node ./script/build --rebuild --config=Debug",
@@ -39,7 +40,7 @@
39
40
  "jsonc": "^2.0.0",
40
41
  "minimist": "^1.2.8",
41
42
  "node-addon-api": "^6.0.0",
42
- "onnx-proto": "^8.0.1"
43
+ "protobufjs": "^7.2.4"
43
44
  },
44
45
  "main": "dist/index.js",
45
46
  "os": [