onnxruntime-node 1.20.0-dev.20241022-2d00351d7b → 1.21.0-dev.20241112-cdc8db9984

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.
Files changed (30) hide show
  1. package/README.md +1 -1
  2. package/__commit.txt +1 -1
  3. package/bin/napi-v3/darwin/arm64/{libonnxruntime.1.20.0.dylib → libonnxruntime.1.21.0.dylib} +0 -0
  4. package/bin/napi-v3/darwin/arm64/onnxruntime_binding.node +0 -0
  5. package/bin/napi-v3/darwin/x64/{libonnxruntime.1.20.0.dylib → libonnxruntime.1.21.0.dylib} +0 -0
  6. package/bin/napi-v3/darwin/x64/onnxruntime_binding.node +0 -0
  7. package/bin/napi-v3/linux/arm64/libonnxruntime.so.1 +0 -0
  8. package/bin/napi-v3/linux/arm64/{libonnxruntime.so.1.20.0 → libonnxruntime.so.1.21.0} +0 -0
  9. package/bin/napi-v3/linux/arm64/onnxruntime_binding.node +0 -0
  10. package/bin/napi-v3/linux/x64/libonnxruntime.so.1 +0 -0
  11. package/bin/napi-v3/linux/x64/{libonnxruntime.so.1.20.0 → libonnxruntime.so.1.21.0} +0 -0
  12. package/bin/napi-v3/linux/x64/libonnxruntime_providers_shared.so +0 -0
  13. package/bin/napi-v3/linux/x64/onnxruntime_binding.node +0 -0
  14. package/bin/napi-v3/win32/arm64/DirectML.dll +0 -0
  15. package/bin/napi-v3/win32/arm64/onnxruntime.dll +0 -0
  16. package/bin/napi-v3/win32/arm64/onnxruntime_binding.node +0 -0
  17. package/bin/napi-v3/win32/x64/DirectML.dll +0 -0
  18. package/bin/napi-v3/win32/x64/onnxruntime.dll +0 -0
  19. package/bin/napi-v3/win32/x64/onnxruntime_binding.node +0 -0
  20. package/dist/backend.js +5 -2
  21. package/dist/backend.js.map +1 -1
  22. package/dist/binding.js +32 -1
  23. package/dist/binding.js.map +1 -1
  24. package/dist/version.js +1 -1
  25. package/lib/backend.ts +7 -3
  26. package/lib/binding.ts +34 -1
  27. package/lib/version.ts +1 -1
  28. package/package.json +2 -2
  29. package/script/build.js +5 -0
  30. package/script/build.ts +5 -0
package/README.md CHANGED
@@ -14,7 +14,7 @@ Refer to [ONNX Runtime JavaScript examples](https://github.com/microsoft/onnxrun
14
14
 
15
15
  ## Requirements
16
16
 
17
- ONNXRuntime works on Node.js v16.x+ (recommend v18.x+) or Electron v15.x+ (recommend v28.x+).
17
+ ONNXRuntime works on Node.js v16.x+ (recommend v20.x+) or Electron v15.x+ (recommend v28.x+).
18
18
 
19
19
  The following table lists the supported versions of ONNX Runtime Node.js binding provided with pre-built binaries.
20
20
 
package/__commit.txt CHANGED
@@ -1 +1 @@
1
- 2d00351d7b4975a4d03f6a437772b6976726a252
1
+ cdc8db998475d6b259119fa89531f88a1172c3a9
Binary file
package/dist/backend.js CHANGED
@@ -19,6 +19,7 @@ const binding_1 = require("./binding");
19
19
  class OnnxruntimeSessionHandler {
20
20
  constructor(pathOrBuffer, options) {
21
21
  _OnnxruntimeSessionHandler_inferenceSession.set(this, void 0);
22
+ (0, binding_1.initOrt)();
22
23
  __classPrivateFieldSet(this, _OnnxruntimeSessionHandler_inferenceSession, new binding_1.binding.InferenceSession(), "f");
23
24
  if (typeof pathOrBuffer === 'string') {
24
25
  __classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").loadModel(pathOrBuffer, options);
@@ -33,10 +34,12 @@ class OnnxruntimeSessionHandler {
33
34
  __classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").dispose();
34
35
  }
35
36
  startProfiling() {
36
- // TODO: implement profiling
37
+ // startProfiling is a no-op.
38
+ //
39
+ // if sessionOptions.enableProfiling is true, profiling will be enabled when the model is loaded.
37
40
  }
38
41
  endProfiling() {
39
- // TODO: implement profiling
42
+ __classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").endProfiling();
40
43
  }
41
44
  async run(feeds, fetches, options) {
42
45
  return new Promise((resolve, reject) => {
@@ -1 +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AAC,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"}
package/dist/binding.js CHANGED
@@ -2,9 +2,40 @@
2
2
  // Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.binding = void 0;
5
+ exports.initOrt = exports.binding = void 0;
6
+ const onnxruntime_common_1 = require("onnxruntime-common");
6
7
  // export native binding
7
8
  exports.binding =
8
9
  // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
9
10
  require(`../bin/napi-v3/${process.platform}/${process.arch}/onnxruntime_binding.node`);
11
+ let ortInitialized = false;
12
+ const initOrt = () => {
13
+ if (!ortInitialized) {
14
+ ortInitialized = true;
15
+ let logLevel = 2;
16
+ if (onnxruntime_common_1.env.logLevel) {
17
+ switch (onnxruntime_common_1.env.logLevel) {
18
+ case 'verbose':
19
+ logLevel = 0;
20
+ break;
21
+ case 'info':
22
+ logLevel = 1;
23
+ break;
24
+ case 'warning':
25
+ logLevel = 2;
26
+ break;
27
+ case 'error':
28
+ logLevel = 3;
29
+ break;
30
+ case 'fatal':
31
+ logLevel = 4;
32
+ break;
33
+ default:
34
+ throw new Error(`Unsupported log level: ${onnxruntime_common_1.env.logLevel}`);
35
+ }
36
+ }
37
+ exports.binding.initOrtOnce(logLevel, onnxruntime_common_1.Tensor);
38
+ }
39
+ };
40
+ exports.initOrt = initOrt;
10
41
  //# sourceMappingURL=binding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AA0ClC,wBAAwB;AACX,QAAA,OAAO;AAClB,qGAAqG;AACrG,OAAO,CAAC,kBAAkB,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,2BAA2B,CAIpF,CAAC"}
1
+ {"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,2DAAiG;AA0CjG,wBAAwB;AACX,QAAA,OAAO;AAClB,qGAAqG;AACrG,OAAO,CAAC,kBAAkB,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,2BAA2B,CAKpF,CAAC;AAEJ,IAAI,cAAc,GAAG,KAAK,CAAC;AACpB,MAAM,OAAO,GAAG,GAAS,EAAE;IAChC,IAAI,CAAC,cAAc,EAAE;QACnB,cAAc,GAAG,IAAI,CAAC;QACtB,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,wBAAG,CAAC,QAAQ,EAAE;YAChB,QAAQ,wBAAG,CAAC,QAAQ,EAAE;gBACpB,KAAK,SAAS;oBACZ,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR,KAAK,MAAM;oBACT,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR,KAAK,SAAS;oBACZ,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR,KAAK,OAAO;oBACV,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR,KAAK,OAAO;oBACV,QAAQ,GAAG,CAAC,CAAC;oBACb,MAAM;gBACR;oBACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,wBAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;aAC7D;SACF;QACD,eAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,2BAAM,CAAC,CAAC;KACvC;AACH,CAAC,CAAC;AA3BW,QAAA,OAAO,WA2BlB"}
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.20.0-dev.20241022-2d00351d7b';
8
+ exports.version = '1.21.0-dev.20241112-cdc8db9984';
9
9
  //# sourceMappingURL=version.js.map
package/lib/backend.ts CHANGED
@@ -3,12 +3,14 @@
3
3
 
4
4
  import { Backend, InferenceSession, InferenceSessionHandler, SessionHandler } from 'onnxruntime-common';
5
5
 
6
- import { Binding, binding } from './binding';
6
+ import { Binding, binding, initOrt } from './binding';
7
7
 
8
8
  class OnnxruntimeSessionHandler implements InferenceSessionHandler {
9
9
  #inferenceSession: Binding.InferenceSession;
10
10
 
11
11
  constructor(pathOrBuffer: string | Uint8Array, options: InferenceSession.SessionOptions) {
12
+ initOrt();
13
+
12
14
  this.#inferenceSession = new binding.InferenceSession();
13
15
  if (typeof pathOrBuffer === 'string') {
14
16
  this.#inferenceSession.loadModel(pathOrBuffer, options);
@@ -27,10 +29,12 @@ class OnnxruntimeSessionHandler implements InferenceSessionHandler {
27
29
  readonly outputNames: string[];
28
30
 
29
31
  startProfiling(): void {
30
- // TODO: implement profiling
32
+ // startProfiling is a no-op.
33
+ //
34
+ // if sessionOptions.enableProfiling is true, profiling will be enabled when the model is loaded.
31
35
  }
32
36
  endProfiling(): void {
33
- // TODO: implement profiling
37
+ this.#inferenceSession.endProfiling();
34
38
  }
35
39
 
36
40
  async run(
package/lib/binding.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
 
4
- import { InferenceSession, OnnxValue } from 'onnxruntime-common';
4
+ import { InferenceSession, OnnxValue, Tensor, TensorConstructor, env } from 'onnxruntime-common';
5
5
 
6
6
  type SessionOptions = InferenceSession.SessionOptions;
7
7
  type FeedsType = {
@@ -28,6 +28,8 @@ export declare namespace Binding {
28
28
 
29
29
  run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
30
30
 
31
+ endProfiling(): void;
32
+
31
33
  dispose(): void;
32
34
  }
33
35
 
@@ -48,4 +50,35 @@ export const binding =
48
50
  // eslint-disable-next-line @typescript-eslint/naming-convention
49
51
  InferenceSession: Binding.InferenceSessionConstructor;
50
52
  listSupportedBackends: () => Binding.SupportedBackend[];
53
+ initOrtOnce: (logLevel: number, tensorConstructor: TensorConstructor) => void;
51
54
  };
55
+
56
+ let ortInitialized = false;
57
+ export const initOrt = (): void => {
58
+ if (!ortInitialized) {
59
+ ortInitialized = true;
60
+ let logLevel = 2;
61
+ if (env.logLevel) {
62
+ switch (env.logLevel) {
63
+ case 'verbose':
64
+ logLevel = 0;
65
+ break;
66
+ case 'info':
67
+ logLevel = 1;
68
+ break;
69
+ case 'warning':
70
+ logLevel = 2;
71
+ break;
72
+ case 'error':
73
+ logLevel = 3;
74
+ break;
75
+ case 'fatal':
76
+ logLevel = 4;
77
+ break;
78
+ default:
79
+ throw new Error(`Unsupported log level: ${env.logLevel}`);
80
+ }
81
+ }
82
+ binding.initOrtOnce(logLevel, Tensor);
83
+ }
84
+ };
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.20.0-dev.20241022-2d00351d7b';
7
+ export const version = '1.21.0-dev.20241112-cdc8db9984';
package/package.json CHANGED
@@ -13,9 +13,9 @@
13
13
  3
14
14
  ]
15
15
  },
16
- "version": "1.20.0-dev.20241022-2d00351d7b",
16
+ "version": "1.21.0-dev.20241112-cdc8db9984",
17
17
  "dependencies": {
18
- "onnxruntime-common": "1.20.0-dev.20241016-2b8fc5529b",
18
+ "onnxruntime-common": "1.21.0-dev.20241026-05fbb43b34",
19
19
  "tar": "^7.0.1"
20
20
  },
21
21
  "scripts": {
package/script/build.js CHANGED
@@ -72,6 +72,8 @@ const ONNXRUNTIME_GENERATOR = buildArgs['onnxruntime-generator'];
72
72
  const REBUILD = !!buildArgs.rebuild;
73
73
  // --use_dml
74
74
  const USE_DML = !!buildArgs.use_dml;
75
+ // --use_webgpu
76
+ const USE_WEBGPU = !!buildArgs.use_webgpu;
75
77
  // --use_cuda
76
78
  const USE_CUDA = !!buildArgs.use_cuda;
77
79
  // --use_tensorrt
@@ -105,6 +107,9 @@ if (ONNXRUNTIME_GENERATOR && typeof ONNXRUNTIME_GENERATOR === 'string') {
105
107
  if (USE_DML) {
106
108
  args.push('--CDUSE_DML=ON');
107
109
  }
110
+ if (USE_WEBGPU) {
111
+ args.push('--CDUSE_WEBGPU=ON');
112
+ }
108
113
  if (USE_CUDA) {
109
114
  args.push('--CDUSE_CUDA=ON');
110
115
  }
package/script/build.ts CHANGED
@@ -29,6 +29,8 @@ const ONNXRUNTIME_GENERATOR = buildArgs['onnxruntime-generator'];
29
29
  const REBUILD = !!buildArgs.rebuild;
30
30
  // --use_dml
31
31
  const USE_DML = !!buildArgs.use_dml;
32
+ // --use_webgpu
33
+ const USE_WEBGPU = !!buildArgs.use_webgpu;
32
34
  // --use_cuda
33
35
  const USE_CUDA = !!buildArgs.use_cuda;
34
36
  // --use_tensorrt
@@ -65,6 +67,9 @@ if (ONNXRUNTIME_GENERATOR && typeof ONNXRUNTIME_GENERATOR === 'string') {
65
67
  if (USE_DML) {
66
68
  args.push('--CDUSE_DML=ON');
67
69
  }
70
+ if (USE_WEBGPU) {
71
+ args.push('--CDUSE_WEBGPU=ON');
72
+ }
68
73
  if (USE_CUDA) {
69
74
  args.push('--CDUSE_CUDA=ON');
70
75
  }