onnxruntime-node 1.20.0 → 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.
- package/README.md +1 -1
- package/__commit.txt +1 -0
- package/bin/napi-v3/darwin/arm64/{libonnxruntime.1.20.0.dylib → libonnxruntime.1.21.0.dylib} +0 -0
- package/bin/napi-v3/darwin/arm64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/darwin/x64/{libonnxruntime.1.20.0.dylib → libonnxruntime.1.21.0.dylib} +0 -0
- package/bin/napi-v3/darwin/x64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/linux/arm64/libonnxruntime.so.1 +0 -0
- package/bin/napi-v3/linux/arm64/{libonnxruntime.so.1.20.0 → libonnxruntime.so.1.21.0} +0 -0
- package/bin/napi-v3/linux/arm64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/linux/x64/libonnxruntime.so.1 +0 -0
- package/bin/napi-v3/linux/x64/{libonnxruntime.so.1.20.0 → libonnxruntime.so.1.21.0} +0 -0
- package/bin/napi-v3/linux/x64/libonnxruntime_providers_shared.so +0 -0
- package/bin/napi-v3/linux/x64/onnxruntime_binding.node +0 -0
- package/bin/napi-v3/win32/arm64/DirectML.dll +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/x64/DirectML.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/dist/backend.js +5 -2
- package/dist/backend.js.map +1 -1
- package/dist/binding.js +32 -1
- package/dist/binding.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/lib/backend.ts +7 -3
- package/lib/binding.ts +34 -1
- package/lib/version.ts +1 -1
- package/package.json +2 -2
- package/script/build.js +95 -67
- package/script/build.ts +5 -0
- package/script/prepack.js +49 -32
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
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cdc8db998475d6b259119fa89531f88a1172c3a9
|
package/bin/napi-v3/darwin/arm64/{libonnxruntime.1.20.0.dylib → libonnxruntime.1.21.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
|
|
Binary file
|
|
Binary file
|
|
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
|
-
//
|
|
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
|
-
|
|
42
|
+
__classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").endProfiling();
|
|
40
43
|
}
|
|
41
44
|
async run(feeds, fetches, options) {
|
|
42
45
|
return new Promise((resolve, reject) => {
|
package/dist/backend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../lib/backend.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;AAIlC,
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../lib/backend.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;AAIlC,uCAAsD;AAEtD,MAAM,yBAAyB;IAG7B,YAAY,YAAiC,EAAE,OAAwC;QAFvF,8DAA4C;QAG1C,IAAA,iBAAO,GAAE,CAAC;QAEV,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,uBAAA,IAAI,mDAAkB,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAKD,cAAc;QACZ,6BAA6B;QAC7B,EAAE;QACF,iGAAiG;IACnG,CAAC;IACD,YAAY;QACV,uBAAA,IAAI,mDAAkB,CAAC,YAAY,EAAE,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,GAAG,CACP,KAA+B,EAC/B,OAAmC,EACnC,OAAoC;QAEpC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,YAAY,CAAC,GAAG,EAAE;gBAChB,IAAI;oBACF,OAAO,CAAC,uBAAA,IAAI,mDAAkB,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;iBAC9D;gBAAC,OAAO,CAAC,EAAE;oBACV,gCAAgC;oBAChC,MAAM,CAAC,CAAC,CAAC,CAAC;iBACX;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;;AAED,MAAM,kBAAkB;IACtB,KAAK,CAAC,IAAI;QACR,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,6BAA6B,CACjC,YAAiC,EACjC,OAAyC;QAEzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,YAAY,CAAC,GAAG,EAAE;gBAChB,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"}
|
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
|
package/dist/binding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;
|
|
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.
|
|
8
|
+
exports.version = '1.21.0-dev.20241112-cdc8db9984';
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
package/dist/version.js.map
CHANGED
|
@@ -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,
|
|
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
|
@@ -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
|
-
//
|
|
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
|
-
|
|
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
package/package.json
CHANGED
package/script/build.js
CHANGED
|
@@ -1,49 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
|
-
var __createBinding =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
4
|
+
var __createBinding =
|
|
5
|
+
(this && this.__createBinding) ||
|
|
6
|
+
(Object.create
|
|
7
|
+
? function (o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return m[k];
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}
|
|
20
|
+
: function (o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
});
|
|
24
|
+
var __setModuleDefault =
|
|
25
|
+
(this && this.__setModuleDefault) ||
|
|
26
|
+
(Object.create
|
|
27
|
+
? function (o, v) {
|
|
28
|
+
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
29
|
+
}
|
|
30
|
+
: function (o, v) {
|
|
31
|
+
o['default'] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar =
|
|
34
|
+
(this && this.__importStar) ||
|
|
35
|
+
function (mod) {
|
|
21
36
|
if (mod && mod.__esModule) return mod;
|
|
22
37
|
var result = {};
|
|
23
|
-
if (mod != null)
|
|
38
|
+
if (mod != null)
|
|
39
|
+
for (var k in mod)
|
|
40
|
+
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
41
|
__setModuleDefault(result, mod);
|
|
25
42
|
return result;
|
|
26
|
-
};
|
|
27
|
-
var __importDefault =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
43
|
+
};
|
|
44
|
+
var __importDefault =
|
|
45
|
+
(this && this.__importDefault) ||
|
|
46
|
+
function (mod) {
|
|
47
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
const child_process_1 = require('child_process');
|
|
51
|
+
const fs = __importStar(require('fs-extra'));
|
|
52
|
+
const minimist_1 = __importDefault(require('minimist'));
|
|
53
|
+
const os = __importStar(require('os'));
|
|
54
|
+
const path = __importStar(require('path'));
|
|
36
55
|
// command line flags
|
|
37
56
|
const buildArgs = (0, minimist_1.default)(process.argv.slice(2));
|
|
38
57
|
// --config=Debug|Release|RelWithDebInfo
|
|
39
58
|
const CONFIG = buildArgs.config || (os.platform() === 'win32' ? 'RelWithDebInfo' : 'Release');
|
|
40
59
|
if (CONFIG !== 'Debug' && CONFIG !== 'Release' && CONFIG !== 'RelWithDebInfo') {
|
|
41
|
-
|
|
60
|
+
throw new Error(`unrecognized config: ${CONFIG}`);
|
|
42
61
|
}
|
|
43
62
|
// --arch=x64|ia32|arm64|arm
|
|
44
63
|
const ARCH = buildArgs.arch || os.arch();
|
|
45
64
|
if (ARCH !== 'x64' && ARCH !== 'ia32' && ARCH !== 'arm64' && ARCH !== 'arm') {
|
|
46
|
-
|
|
65
|
+
throw new Error(`unrecognized architecture: ${ARCH}`);
|
|
47
66
|
}
|
|
48
67
|
// --onnxruntime-build-dir=
|
|
49
68
|
const ONNXRUNTIME_BUILD_DIR = buildArgs['onnxruntime-build-dir'];
|
|
@@ -53,6 +72,8 @@ const ONNXRUNTIME_GENERATOR = buildArgs['onnxruntime-generator'];
|
|
|
53
72
|
const REBUILD = !!buildArgs.rebuild;
|
|
54
73
|
// --use_dml
|
|
55
74
|
const USE_DML = !!buildArgs.use_dml;
|
|
75
|
+
// --use_webgpu
|
|
76
|
+
const USE_WEBGPU = !!buildArgs.use_webgpu;
|
|
56
77
|
// --use_cuda
|
|
57
78
|
const USE_CUDA = !!buildArgs.use_cuda;
|
|
58
79
|
// --use_tensorrt
|
|
@@ -67,72 +88,79 @@ const BIN_FOLDER = path.join(ROOT_FOLDER, 'bin');
|
|
|
67
88
|
const BUILD_FOLDER = path.join(ROOT_FOLDER, 'build');
|
|
68
89
|
// if rebuild, clean up the dist folders
|
|
69
90
|
if (REBUILD) {
|
|
70
|
-
|
|
71
|
-
|
|
91
|
+
fs.removeSync(BIN_FOLDER);
|
|
92
|
+
fs.removeSync(BUILD_FOLDER);
|
|
72
93
|
}
|
|
73
94
|
const args = [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
95
|
+
'cmake-js',
|
|
96
|
+
REBUILD ? 'reconfigure' : 'configure',
|
|
97
|
+
`--arch=${ARCH}`,
|
|
98
|
+
'--CDnapi_build_version=6',
|
|
99
|
+
`--CDCMAKE_BUILD_TYPE=${CONFIG}`,
|
|
79
100
|
];
|
|
80
101
|
if (ONNXRUNTIME_BUILD_DIR && typeof ONNXRUNTIME_BUILD_DIR === 'string') {
|
|
81
|
-
|
|
102
|
+
args.push(`--CDONNXRUNTIME_BUILD_DIR=${ONNXRUNTIME_BUILD_DIR}`);
|
|
82
103
|
}
|
|
83
104
|
if (ONNXRUNTIME_GENERATOR && typeof ONNXRUNTIME_GENERATOR === 'string') {
|
|
84
|
-
|
|
105
|
+
args.push(`--CDONNXRUNTIME_GENERATOR=${ONNXRUNTIME_GENERATOR}`);
|
|
85
106
|
}
|
|
86
107
|
if (USE_DML) {
|
|
87
|
-
|
|
108
|
+
args.push('--CDUSE_DML=ON');
|
|
109
|
+
}
|
|
110
|
+
if (USE_WEBGPU) {
|
|
111
|
+
args.push('--CDUSE_WEBGPU=ON');
|
|
88
112
|
}
|
|
89
113
|
if (USE_CUDA) {
|
|
90
|
-
|
|
114
|
+
args.push('--CDUSE_CUDA=ON');
|
|
91
115
|
}
|
|
92
116
|
if (USE_TENSORRT) {
|
|
93
|
-
|
|
117
|
+
args.push('--CDUSE_TENSORRT=ON');
|
|
94
118
|
}
|
|
95
119
|
if (USE_COREML) {
|
|
96
|
-
|
|
120
|
+
args.push('--CDUSE_COREML=ON');
|
|
97
121
|
}
|
|
98
122
|
if (USE_QNN) {
|
|
99
|
-
|
|
123
|
+
args.push('--CDUSE_QNN=ON');
|
|
100
124
|
}
|
|
101
125
|
// set CMAKE_OSX_ARCHITECTURES for macOS build
|
|
102
126
|
if (os.platform() === 'darwin') {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
throw new Error(`architecture not supported for macOS build: ${ARCH}`);
|
|
111
|
-
}
|
|
127
|
+
if (ARCH === 'x64') {
|
|
128
|
+
args.push('--CDCMAKE_OSX_ARCHITECTURES=x86_64');
|
|
129
|
+
} else if (ARCH === 'arm64') {
|
|
130
|
+
args.push('--CDCMAKE_OSX_ARCHITECTURES=arm64');
|
|
131
|
+
} else {
|
|
132
|
+
throw new Error(`architecture not supported for macOS build: ${ARCH}`);
|
|
133
|
+
}
|
|
112
134
|
}
|
|
113
135
|
// In Windows, "npx cmake-js configure" uses a powershell script to detect the Visual Studio installation.
|
|
114
136
|
// The script uses the environment variable LIB. If an invalid path is specified in LIB, the script will fail.
|
|
115
137
|
// So we override the LIB environment variable to remove invalid paths.
|
|
116
|
-
const envOverride =
|
|
138
|
+
const envOverride =
|
|
139
|
+
os.platform() === 'win32' && process.env.LIB
|
|
117
140
|
? { ...process.env, LIB: process.env.LIB.split(';').filter(fs.existsSync).join(';') }
|
|
118
141
|
: process.env;
|
|
119
142
|
// launch cmake-js configure
|
|
120
|
-
const procCmakejs = (0, child_process_1.spawnSync)('npx', args, {
|
|
143
|
+
const procCmakejs = (0, child_process_1.spawnSync)('npx', args, {
|
|
144
|
+
shell: true,
|
|
145
|
+
stdio: 'inherit',
|
|
146
|
+
cwd: ROOT_FOLDER,
|
|
147
|
+
env: envOverride,
|
|
148
|
+
});
|
|
121
149
|
if (procCmakejs.status !== 0) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
150
|
+
if (procCmakejs.error) {
|
|
151
|
+
console.error(procCmakejs.error);
|
|
152
|
+
}
|
|
153
|
+
process.exit(procCmakejs.status === null ? undefined : procCmakejs.status);
|
|
126
154
|
}
|
|
127
155
|
// launch cmake to build
|
|
128
156
|
const procCmake = (0, child_process_1.spawnSync)('cmake', ['--build', '.', '--config', CONFIG], {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
157
|
+
shell: true,
|
|
158
|
+
stdio: 'inherit',
|
|
159
|
+
cwd: BUILD_FOLDER,
|
|
132
160
|
});
|
|
133
161
|
if (procCmake.status !== 0) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
162
|
+
if (procCmake.error) {
|
|
163
|
+
console.error(procCmake.error);
|
|
164
|
+
}
|
|
165
|
+
process.exit(procCmake.status === null ? undefined : procCmake.status);
|
|
138
166
|
}
|
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
|
}
|
package/script/prepack.js
CHANGED
|
@@ -1,42 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
|
-
var __createBinding =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
4
|
+
var __createBinding =
|
|
5
|
+
(this && this.__createBinding) ||
|
|
6
|
+
(Object.create
|
|
7
|
+
? function (o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return m[k];
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}
|
|
20
|
+
: function (o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
});
|
|
24
|
+
var __setModuleDefault =
|
|
25
|
+
(this && this.__setModuleDefault) ||
|
|
26
|
+
(Object.create
|
|
27
|
+
? function (o, v) {
|
|
28
|
+
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
29
|
+
}
|
|
30
|
+
: function (o, v) {
|
|
31
|
+
o['default'] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar =
|
|
34
|
+
(this && this.__importStar) ||
|
|
35
|
+
function (mod) {
|
|
21
36
|
if (mod && mod.__esModule) return mod;
|
|
22
37
|
var result = {};
|
|
23
|
-
if (mod != null)
|
|
38
|
+
if (mod != null)
|
|
39
|
+
for (var k in mod)
|
|
40
|
+
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
41
|
__setModuleDefault(result, mod);
|
|
25
42
|
return result;
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports,
|
|
28
|
-
const fs = __importStar(require(
|
|
29
|
-
const path = __importStar(require(
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
45
|
+
const fs = __importStar(require('fs-extra'));
|
|
46
|
+
const path = __importStar(require('path'));
|
|
30
47
|
function updatePackageJson() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
const commonPackageJsonPath = path.join(__dirname, '..', '..', 'common', 'package.json');
|
|
49
|
+
const selfPackageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
50
|
+
console.log(`=== start to update package.json: ${selfPackageJsonPath}`);
|
|
51
|
+
const packageCommon = fs.readJSONSync(commonPackageJsonPath);
|
|
52
|
+
const packageSelf = fs.readJSONSync(selfPackageJsonPath);
|
|
53
|
+
const version = packageCommon.version;
|
|
54
|
+
packageSelf.dependencies['onnxruntime-common'] = `${version}`;
|
|
55
|
+
fs.writeJSONSync(selfPackageJsonPath, packageSelf, { spaces: 2 });
|
|
56
|
+
console.log('=== finished updating package.json.');
|
|
40
57
|
}
|
|
41
58
|
// update version of dependency "onnxruntime-common" before packing
|
|
42
59
|
updatePackageJson();
|