onnxruntime-node 1.22.0-dev.20250418-c19a49615b → 1.22.0-rev
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 +56 -56
- package/bin/napi-v6/darwin/arm64/libonnxruntime.1.22.0.dylib +0 -0
- package/bin/napi-v6/darwin/x64/libonnxruntime.1.22.0.dylib +0 -0
- package/bin/napi-v6/linux/arm64/libonnxruntime.so.1 +0 -0
- package/bin/napi-v6/linux/x64/libonnxruntime.so.1 +0 -0
- package/bin/napi-v6/win32/arm64/DirectML.dll +0 -0
- package/bin/napi-v6/win32/arm64/dxcompiler.dll +0 -0
- package/bin/napi-v6/win32/arm64/dxil.dll +0 -0
- package/bin/napi-v6/win32/arm64/onnxruntime.dll +0 -0
- package/bin/napi-v6/win32/arm64/onnxruntime_binding.node +0 -0
- package/bin/napi-v6/win32/x64/DirectML.dll +0 -0
- package/bin/napi-v6/win32/x64/dxcompiler.dll +0 -0
- package/bin/napi-v6/win32/x64/dxil.dll +0 -0
- package/bin/napi-v6/win32/x64/onnxruntime.dll +0 -0
- package/bin/napi-v6/win32/x64/onnxruntime_binding.node +0 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/lib/backend.ts +158 -158
- package/lib/binding.ts +91 -91
- package/lib/index.ts +15 -15
- package/lib/version.ts +7 -7
- package/package.json +2 -2
- package/script/build.ts +130 -130
- package/script/install-metadata-versions.js +1 -6
- package/script/install-metadata.js +58 -58
- package/script/install-utils.js +306 -306
- package/script/install.js +134 -134
- package/script/prepack.ts +20 -20
- package/__commit.txt +0 -1
package/lib/binding.ts
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import { InferenceSession, OnnxValue, Tensor, TensorConstructor, env } 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
|
-
* Binding exports a simple synchronized inference session object wrap.
|
|
20
|
-
*/
|
|
21
|
-
export declare namespace Binding {
|
|
22
|
-
export interface ValueMetadata {
|
|
23
|
-
name: string;
|
|
24
|
-
isTensor: boolean;
|
|
25
|
-
symbolicDimensions: string[];
|
|
26
|
-
shape: number[];
|
|
27
|
-
type: number;
|
|
28
|
-
}
|
|
29
|
-
export interface InferenceSession {
|
|
30
|
-
loadModel(modelPath: string, options: SessionOptions): void;
|
|
31
|
-
loadModel(buffer: ArrayBuffer, byteOffset: number, byteLength: number, options: SessionOptions): void;
|
|
32
|
-
|
|
33
|
-
readonly inputMetadata: ValueMetadata[];
|
|
34
|
-
readonly outputMetadata: ValueMetadata[];
|
|
35
|
-
|
|
36
|
-
run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
|
|
37
|
-
|
|
38
|
-
endProfiling(): void;
|
|
39
|
-
|
|
40
|
-
dispose(): void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface InferenceSessionConstructor {
|
|
44
|
-
new (): InferenceSession;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface SupportedBackend {
|
|
48
|
-
name: string;
|
|
49
|
-
bundled: boolean;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// export native binding
|
|
54
|
-
export const binding =
|
|
55
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
56
|
-
require(`../bin/napi-v6/${process.platform}/${process.arch}/onnxruntime_binding.node`) as {
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
58
|
-
InferenceSession: Binding.InferenceSessionConstructor;
|
|
59
|
-
listSupportedBackends: () => Binding.SupportedBackend[];
|
|
60
|
-
initOrtOnce: (logLevel: number, tensorConstructor: TensorConstructor) => void;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
let ortInitialized = false;
|
|
64
|
-
export const initOrt = (): void => {
|
|
65
|
-
if (!ortInitialized) {
|
|
66
|
-
ortInitialized = true;
|
|
67
|
-
let logLevel = 2;
|
|
68
|
-
if (env.logLevel) {
|
|
69
|
-
switch (env.logLevel) {
|
|
70
|
-
case 'verbose':
|
|
71
|
-
logLevel = 0;
|
|
72
|
-
break;
|
|
73
|
-
case 'info':
|
|
74
|
-
logLevel = 1;
|
|
75
|
-
break;
|
|
76
|
-
case 'warning':
|
|
77
|
-
logLevel = 2;
|
|
78
|
-
break;
|
|
79
|
-
case 'error':
|
|
80
|
-
logLevel = 3;
|
|
81
|
-
break;
|
|
82
|
-
case 'fatal':
|
|
83
|
-
logLevel = 4;
|
|
84
|
-
break;
|
|
85
|
-
default:
|
|
86
|
-
throw new Error(`Unsupported log level: ${env.logLevel}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
binding.initOrtOnce(logLevel, Tensor);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import { InferenceSession, OnnxValue, Tensor, TensorConstructor, env } 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
|
+
* Binding exports a simple synchronized inference session object wrap.
|
|
20
|
+
*/
|
|
21
|
+
export declare namespace Binding {
|
|
22
|
+
export interface ValueMetadata {
|
|
23
|
+
name: string;
|
|
24
|
+
isTensor: boolean;
|
|
25
|
+
symbolicDimensions: string[];
|
|
26
|
+
shape: number[];
|
|
27
|
+
type: number;
|
|
28
|
+
}
|
|
29
|
+
export interface InferenceSession {
|
|
30
|
+
loadModel(modelPath: string, options: SessionOptions): void;
|
|
31
|
+
loadModel(buffer: ArrayBuffer, byteOffset: number, byteLength: number, options: SessionOptions): void;
|
|
32
|
+
|
|
33
|
+
readonly inputMetadata: ValueMetadata[];
|
|
34
|
+
readonly outputMetadata: ValueMetadata[];
|
|
35
|
+
|
|
36
|
+
run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
|
|
37
|
+
|
|
38
|
+
endProfiling(): void;
|
|
39
|
+
|
|
40
|
+
dispose(): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface InferenceSessionConstructor {
|
|
44
|
+
new (): InferenceSession;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface SupportedBackend {
|
|
48
|
+
name: string;
|
|
49
|
+
bundled: boolean;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// export native binding
|
|
54
|
+
export const binding =
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
56
|
+
require(`../bin/napi-v6/${process.platform}/${process.arch}/onnxruntime_binding.node`) as {
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
58
|
+
InferenceSession: Binding.InferenceSessionConstructor;
|
|
59
|
+
listSupportedBackends: () => Binding.SupportedBackend[];
|
|
60
|
+
initOrtOnce: (logLevel: number, tensorConstructor: TensorConstructor) => void;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
let ortInitialized = false;
|
|
64
|
+
export const initOrt = (): void => {
|
|
65
|
+
if (!ortInitialized) {
|
|
66
|
+
ortInitialized = true;
|
|
67
|
+
let logLevel = 2;
|
|
68
|
+
if (env.logLevel) {
|
|
69
|
+
switch (env.logLevel) {
|
|
70
|
+
case 'verbose':
|
|
71
|
+
logLevel = 0;
|
|
72
|
+
break;
|
|
73
|
+
case 'info':
|
|
74
|
+
logLevel = 1;
|
|
75
|
+
break;
|
|
76
|
+
case 'warning':
|
|
77
|
+
logLevel = 2;
|
|
78
|
+
break;
|
|
79
|
+
case 'error':
|
|
80
|
+
logLevel = 3;
|
|
81
|
+
break;
|
|
82
|
+
case 'fatal':
|
|
83
|
+
logLevel = 4;
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
throw new Error(`Unsupported log level: ${env.logLevel}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
binding.initOrtOnce(logLevel, Tensor);
|
|
90
|
+
}
|
|
91
|
+
};
|
package/lib/index.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
export * from 'onnxruntime-common';
|
|
5
|
-
export { listSupportedBackends } from './backend';
|
|
6
|
-
import { registerBackend, env } from 'onnxruntime-common';
|
|
7
|
-
import { version } from './version';
|
|
8
|
-
import { onnxruntimeBackend, listSupportedBackends } from './backend';
|
|
9
|
-
|
|
10
|
-
const backends = listSupportedBackends();
|
|
11
|
-
for (const backend of backends) {
|
|
12
|
-
registerBackend(backend.name, onnxruntimeBackend, 100);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(env.versions, 'node', { value: version, enumerable: true });
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
export * from 'onnxruntime-common';
|
|
5
|
+
export { listSupportedBackends } from './backend';
|
|
6
|
+
import { registerBackend, env } from 'onnxruntime-common';
|
|
7
|
+
import { version } from './version';
|
|
8
|
+
import { onnxruntimeBackend, listSupportedBackends } from './backend';
|
|
9
|
+
|
|
10
|
+
const backends = listSupportedBackends();
|
|
11
|
+
for (const backend of backends) {
|
|
12
|
+
registerBackend(backend.name, onnxruntimeBackend, 100);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(env.versions, 'node', { value: version, enumerable: true });
|
package/lib/version.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
// This file is generated by /js/scripts/update-version.ts
|
|
5
|
-
// Do not modify file content manually.
|
|
6
|
-
|
|
7
|
-
export const version = '1.22.0-
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
// This file is generated by /js/scripts/update-version.ts
|
|
5
|
+
// Do not modify file content manually.
|
|
6
|
+
|
|
7
|
+
export const version = '1.22.0-rev';
|
package/package.json
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
6
|
|
12
12
|
]
|
|
13
13
|
},
|
|
14
|
-
"version": "1.22.0-
|
|
14
|
+
"version": "1.22.0-rev",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"adm-zip": "^0.5.16",
|
|
17
17
|
"global-agent": "^3.0.0",
|
|
18
|
-
"onnxruntime-common": "1.22.0
|
|
18
|
+
"onnxruntime-common": "1.22.0"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"postinstall": "node ./script/install",
|
package/script/build.ts
CHANGED
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import { spawnSync } from 'child_process';
|
|
5
|
-
import * as fs from 'fs-extra';
|
|
6
|
-
import minimist from 'minimist';
|
|
7
|
-
import * as os from 'os';
|
|
8
|
-
import * as path from 'path';
|
|
9
|
-
|
|
10
|
-
// command line flags
|
|
11
|
-
const buildArgs = minimist(process.argv.slice(2));
|
|
12
|
-
|
|
13
|
-
// --config=Debug|Release|RelWithDebInfo
|
|
14
|
-
const CONFIG: 'Debug' | 'Release' | 'RelWithDebInfo' =
|
|
15
|
-
buildArgs.config || (os.platform() === 'win32' ? 'RelWithDebInfo' : 'Release');
|
|
16
|
-
if (CONFIG !== 'Debug' && CONFIG !== 'Release' && CONFIG !== 'RelWithDebInfo') {
|
|
17
|
-
throw new Error(`unrecognized config: ${CONFIG}`);
|
|
18
|
-
}
|
|
19
|
-
// --arch=x64|ia32|arm64|arm
|
|
20
|
-
const ARCH: 'x64' | 'ia32' | 'arm64' | 'arm' = buildArgs.arch || os.arch();
|
|
21
|
-
if (ARCH !== 'x64' && ARCH !== 'ia32' && ARCH !== 'arm64' && ARCH !== 'arm') {
|
|
22
|
-
throw new Error(`unrecognized architecture: ${ARCH}`);
|
|
23
|
-
}
|
|
24
|
-
// --onnxruntime-build-dir=
|
|
25
|
-
const ONNXRUNTIME_BUILD_DIR = buildArgs['onnxruntime-build-dir'];
|
|
26
|
-
// --onnxruntime-generator=
|
|
27
|
-
const ONNXRUNTIME_GENERATOR = buildArgs['onnxruntime-generator'];
|
|
28
|
-
// --rebuild
|
|
29
|
-
const REBUILD = !!buildArgs.rebuild;
|
|
30
|
-
// --use_dml
|
|
31
|
-
const USE_DML = !!buildArgs.use_dml;
|
|
32
|
-
// --use_webgpu
|
|
33
|
-
const USE_WEBGPU = !!buildArgs.use_webgpu;
|
|
34
|
-
// --use_cuda
|
|
35
|
-
const USE_CUDA = !!buildArgs.use_cuda;
|
|
36
|
-
// --use_tensorrt
|
|
37
|
-
const USE_TENSORRT = !!buildArgs.use_tensorrt;
|
|
38
|
-
// --use_coreml
|
|
39
|
-
const USE_COREML = !!buildArgs.use_coreml;
|
|
40
|
-
// --use_qnn
|
|
41
|
-
const USE_QNN = !!buildArgs.use_qnn;
|
|
42
|
-
// --dll_deps=
|
|
43
|
-
const DLL_DEPS = buildArgs.dll_deps;
|
|
44
|
-
|
|
45
|
-
// build path
|
|
46
|
-
const ROOT_FOLDER = path.join(__dirname, '..');
|
|
47
|
-
const BIN_FOLDER = path.join(ROOT_FOLDER, 'bin');
|
|
48
|
-
const BUILD_FOLDER = path.join(ROOT_FOLDER, 'build');
|
|
49
|
-
|
|
50
|
-
// if rebuild, clean up the dist folders
|
|
51
|
-
if (REBUILD) {
|
|
52
|
-
fs.removeSync(BIN_FOLDER);
|
|
53
|
-
fs.removeSync(BUILD_FOLDER);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const args = [
|
|
57
|
-
'cmake-js',
|
|
58
|
-
REBUILD ? 'reconfigure' : 'configure',
|
|
59
|
-
`--arch=${ARCH}`,
|
|
60
|
-
'--CDnapi_build_version=6',
|
|
61
|
-
`--CDCMAKE_BUILD_TYPE=${CONFIG}`,
|
|
62
|
-
];
|
|
63
|
-
if (ONNXRUNTIME_BUILD_DIR && typeof ONNXRUNTIME_BUILD_DIR === 'string') {
|
|
64
|
-
args.push(`--CDONNXRUNTIME_BUILD_DIR=${ONNXRUNTIME_BUILD_DIR}`);
|
|
65
|
-
}
|
|
66
|
-
if (ONNXRUNTIME_GENERATOR && typeof ONNXRUNTIME_GENERATOR === 'string') {
|
|
67
|
-
args.push(`--CDONNXRUNTIME_GENERATOR=${ONNXRUNTIME_GENERATOR}`);
|
|
68
|
-
}
|
|
69
|
-
if (USE_DML) {
|
|
70
|
-
args.push('--CDUSE_DML=ON');
|
|
71
|
-
}
|
|
72
|
-
if (USE_WEBGPU) {
|
|
73
|
-
args.push('--CDUSE_WEBGPU=ON');
|
|
74
|
-
}
|
|
75
|
-
if (USE_CUDA) {
|
|
76
|
-
args.push('--CDUSE_CUDA=ON');
|
|
77
|
-
}
|
|
78
|
-
if (USE_TENSORRT) {
|
|
79
|
-
args.push('--CDUSE_TENSORRT=ON');
|
|
80
|
-
}
|
|
81
|
-
if (USE_COREML) {
|
|
82
|
-
args.push('--CDUSE_COREML=ON');
|
|
83
|
-
}
|
|
84
|
-
if (USE_QNN) {
|
|
85
|
-
args.push('--CDUSE_QNN=ON');
|
|
86
|
-
}
|
|
87
|
-
if (DLL_DEPS) {
|
|
88
|
-
args.push(`--CDORT_NODEJS_DLL_DEPS=${DLL_DEPS}`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// set CMAKE_OSX_ARCHITECTURES for macOS build
|
|
92
|
-
if (os.platform() === 'darwin') {
|
|
93
|
-
if (ARCH === 'x64') {
|
|
94
|
-
args.push('--CDCMAKE_OSX_ARCHITECTURES=x86_64');
|
|
95
|
-
} else if (ARCH === 'arm64') {
|
|
96
|
-
args.push('--CDCMAKE_OSX_ARCHITECTURES=arm64');
|
|
97
|
-
} else {
|
|
98
|
-
throw new Error(`architecture not supported for macOS build: ${ARCH}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// In Windows, "npx cmake-js configure" uses a powershell script to detect the Visual Studio installation.
|
|
103
|
-
// The script uses the environment variable LIB. If an invalid path is specified in LIB, the script will fail.
|
|
104
|
-
// So we override the LIB environment variable to remove invalid paths.
|
|
105
|
-
const envOverride =
|
|
106
|
-
os.platform() === 'win32' && process.env.LIB
|
|
107
|
-
? { ...process.env, LIB: process.env.LIB.split(';').filter(fs.existsSync).join(';') }
|
|
108
|
-
: process.env;
|
|
109
|
-
|
|
110
|
-
// launch cmake-js configure
|
|
111
|
-
const procCmakejs = spawnSync('npx', args, { shell: true, stdio: 'inherit', cwd: ROOT_FOLDER, env: envOverride });
|
|
112
|
-
if (procCmakejs.status !== 0) {
|
|
113
|
-
if (procCmakejs.error) {
|
|
114
|
-
console.error(procCmakejs.error);
|
|
115
|
-
}
|
|
116
|
-
process.exit(procCmakejs.status === null ? undefined : procCmakejs.status);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// launch cmake to build
|
|
120
|
-
const procCmake = spawnSync('cmake', ['--build', '.', '--config', CONFIG], {
|
|
121
|
-
shell: true,
|
|
122
|
-
stdio: 'inherit',
|
|
123
|
-
cwd: BUILD_FOLDER,
|
|
124
|
-
});
|
|
125
|
-
if (procCmake.status !== 0) {
|
|
126
|
-
if (procCmake.error) {
|
|
127
|
-
console.error(procCmake.error);
|
|
128
|
-
}
|
|
129
|
-
process.exit(procCmake.status === null ? undefined : procCmake.status);
|
|
130
|
-
}
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import { spawnSync } from 'child_process';
|
|
5
|
+
import * as fs from 'fs-extra';
|
|
6
|
+
import minimist from 'minimist';
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
|
|
10
|
+
// command line flags
|
|
11
|
+
const buildArgs = minimist(process.argv.slice(2));
|
|
12
|
+
|
|
13
|
+
// --config=Debug|Release|RelWithDebInfo
|
|
14
|
+
const CONFIG: 'Debug' | 'Release' | 'RelWithDebInfo' =
|
|
15
|
+
buildArgs.config || (os.platform() === 'win32' ? 'RelWithDebInfo' : 'Release');
|
|
16
|
+
if (CONFIG !== 'Debug' && CONFIG !== 'Release' && CONFIG !== 'RelWithDebInfo') {
|
|
17
|
+
throw new Error(`unrecognized config: ${CONFIG}`);
|
|
18
|
+
}
|
|
19
|
+
// --arch=x64|ia32|arm64|arm
|
|
20
|
+
const ARCH: 'x64' | 'ia32' | 'arm64' | 'arm' = buildArgs.arch || os.arch();
|
|
21
|
+
if (ARCH !== 'x64' && ARCH !== 'ia32' && ARCH !== 'arm64' && ARCH !== 'arm') {
|
|
22
|
+
throw new Error(`unrecognized architecture: ${ARCH}`);
|
|
23
|
+
}
|
|
24
|
+
// --onnxruntime-build-dir=
|
|
25
|
+
const ONNXRUNTIME_BUILD_DIR = buildArgs['onnxruntime-build-dir'];
|
|
26
|
+
// --onnxruntime-generator=
|
|
27
|
+
const ONNXRUNTIME_GENERATOR = buildArgs['onnxruntime-generator'];
|
|
28
|
+
// --rebuild
|
|
29
|
+
const REBUILD = !!buildArgs.rebuild;
|
|
30
|
+
// --use_dml
|
|
31
|
+
const USE_DML = !!buildArgs.use_dml;
|
|
32
|
+
// --use_webgpu
|
|
33
|
+
const USE_WEBGPU = !!buildArgs.use_webgpu;
|
|
34
|
+
// --use_cuda
|
|
35
|
+
const USE_CUDA = !!buildArgs.use_cuda;
|
|
36
|
+
// --use_tensorrt
|
|
37
|
+
const USE_TENSORRT = !!buildArgs.use_tensorrt;
|
|
38
|
+
// --use_coreml
|
|
39
|
+
const USE_COREML = !!buildArgs.use_coreml;
|
|
40
|
+
// --use_qnn
|
|
41
|
+
const USE_QNN = !!buildArgs.use_qnn;
|
|
42
|
+
// --dll_deps=
|
|
43
|
+
const DLL_DEPS = buildArgs.dll_deps;
|
|
44
|
+
|
|
45
|
+
// build path
|
|
46
|
+
const ROOT_FOLDER = path.join(__dirname, '..');
|
|
47
|
+
const BIN_FOLDER = path.join(ROOT_FOLDER, 'bin');
|
|
48
|
+
const BUILD_FOLDER = path.join(ROOT_FOLDER, 'build');
|
|
49
|
+
|
|
50
|
+
// if rebuild, clean up the dist folders
|
|
51
|
+
if (REBUILD) {
|
|
52
|
+
fs.removeSync(BIN_FOLDER);
|
|
53
|
+
fs.removeSync(BUILD_FOLDER);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const args = [
|
|
57
|
+
'cmake-js',
|
|
58
|
+
REBUILD ? 'reconfigure' : 'configure',
|
|
59
|
+
`--arch=${ARCH}`,
|
|
60
|
+
'--CDnapi_build_version=6',
|
|
61
|
+
`--CDCMAKE_BUILD_TYPE=${CONFIG}`,
|
|
62
|
+
];
|
|
63
|
+
if (ONNXRUNTIME_BUILD_DIR && typeof ONNXRUNTIME_BUILD_DIR === 'string') {
|
|
64
|
+
args.push(`--CDONNXRUNTIME_BUILD_DIR=${ONNXRUNTIME_BUILD_DIR}`);
|
|
65
|
+
}
|
|
66
|
+
if (ONNXRUNTIME_GENERATOR && typeof ONNXRUNTIME_GENERATOR === 'string') {
|
|
67
|
+
args.push(`--CDONNXRUNTIME_GENERATOR=${ONNXRUNTIME_GENERATOR}`);
|
|
68
|
+
}
|
|
69
|
+
if (USE_DML) {
|
|
70
|
+
args.push('--CDUSE_DML=ON');
|
|
71
|
+
}
|
|
72
|
+
if (USE_WEBGPU) {
|
|
73
|
+
args.push('--CDUSE_WEBGPU=ON');
|
|
74
|
+
}
|
|
75
|
+
if (USE_CUDA) {
|
|
76
|
+
args.push('--CDUSE_CUDA=ON');
|
|
77
|
+
}
|
|
78
|
+
if (USE_TENSORRT) {
|
|
79
|
+
args.push('--CDUSE_TENSORRT=ON');
|
|
80
|
+
}
|
|
81
|
+
if (USE_COREML) {
|
|
82
|
+
args.push('--CDUSE_COREML=ON');
|
|
83
|
+
}
|
|
84
|
+
if (USE_QNN) {
|
|
85
|
+
args.push('--CDUSE_QNN=ON');
|
|
86
|
+
}
|
|
87
|
+
if (DLL_DEPS) {
|
|
88
|
+
args.push(`--CDORT_NODEJS_DLL_DEPS=${DLL_DEPS}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// set CMAKE_OSX_ARCHITECTURES for macOS build
|
|
92
|
+
if (os.platform() === 'darwin') {
|
|
93
|
+
if (ARCH === 'x64') {
|
|
94
|
+
args.push('--CDCMAKE_OSX_ARCHITECTURES=x86_64');
|
|
95
|
+
} else if (ARCH === 'arm64') {
|
|
96
|
+
args.push('--CDCMAKE_OSX_ARCHITECTURES=arm64');
|
|
97
|
+
} else {
|
|
98
|
+
throw new Error(`architecture not supported for macOS build: ${ARCH}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// In Windows, "npx cmake-js configure" uses a powershell script to detect the Visual Studio installation.
|
|
103
|
+
// The script uses the environment variable LIB. If an invalid path is specified in LIB, the script will fail.
|
|
104
|
+
// So we override the LIB environment variable to remove invalid paths.
|
|
105
|
+
const envOverride =
|
|
106
|
+
os.platform() === 'win32' && process.env.LIB
|
|
107
|
+
? { ...process.env, LIB: process.env.LIB.split(';').filter(fs.existsSync).join(';') }
|
|
108
|
+
: process.env;
|
|
109
|
+
|
|
110
|
+
// launch cmake-js configure
|
|
111
|
+
const procCmakejs = spawnSync('npx', args, { shell: true, stdio: 'inherit', cwd: ROOT_FOLDER, env: envOverride });
|
|
112
|
+
if (procCmakejs.status !== 0) {
|
|
113
|
+
if (procCmakejs.error) {
|
|
114
|
+
console.error(procCmakejs.error);
|
|
115
|
+
}
|
|
116
|
+
process.exit(procCmakejs.status === null ? undefined : procCmakejs.status);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// launch cmake to build
|
|
120
|
+
const procCmake = spawnSync('cmake', ['--build', '.', '--config', CONFIG], {
|
|
121
|
+
shell: true,
|
|
122
|
+
stdio: 'inherit',
|
|
123
|
+
cwd: BUILD_FOLDER,
|
|
124
|
+
});
|
|
125
|
+
if (procCmake.status !== 0) {
|
|
126
|
+
if (procCmake.error) {
|
|
127
|
+
console.error(procCmake.error);
|
|
128
|
+
}
|
|
129
|
+
process.exit(procCmake.status === null ? undefined : procCmake.status);
|
|
130
|
+
}
|
|
@@ -4,9 +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
|
-
module.exports = {
|
|
8
|
-
nuget: [
|
|
9
|
-
{ feed: 'nuget_nightly', version: '1.22.0-dev-20250418-1104-c19a49615b' },
|
|
10
|
-
{ feed: 'nuget_nightly', version: '1.22.0-dev-20250409-0707-89f8206ba4' },
|
|
11
|
-
],
|
|
12
|
-
};
|
|
7
|
+
module.exports = { nuget: [{ feed: 'nuget', version: '1.22.0' }] };
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
const metadataVersions = require('./install-metadata-versions.js');
|
|
7
|
-
|
|
8
|
-
const metadata = {
|
|
9
|
-
// Requirements defines a list of manifest to install for a specific platform/architecture combination.
|
|
10
|
-
requirements: {
|
|
11
|
-
'win32/x64': [],
|
|
12
|
-
'win32/arm64': [],
|
|
13
|
-
'linux/x64': ['cuda12'],
|
|
14
|
-
'linux/arm64': [],
|
|
15
|
-
'darwin/x64': [],
|
|
16
|
-
'darwin/arm64': [],
|
|
17
|
-
},
|
|
18
|
-
// Each manifest defines a list of files to install
|
|
19
|
-
manifests: {
|
|
20
|
-
'linux/x64:cuda12': {
|
|
21
|
-
'./libonnxruntime_providers_cuda.so': {
|
|
22
|
-
package: 'nuget:linux/x64:cuda12',
|
|
23
|
-
path: 'runtimes/
|
|
24
|
-
},
|
|
25
|
-
'./libonnxruntime_providers_shared.so': {
|
|
26
|
-
package: 'nuget:linux/x64:cuda12',
|
|
27
|
-
path: 'runtimes/
|
|
28
|
-
},
|
|
29
|
-
'./libonnxruntime_providers_tensorrt.so': {
|
|
30
|
-
package: 'nuget:linux/x64:cuda12',
|
|
31
|
-
path: 'runtimes/
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
// Each package defines a list of package metadata. The first available package will be used.
|
|
36
|
-
packages: {
|
|
37
|
-
'nuget:win32/x64:cuda12': {
|
|
38
|
-
name: 'Microsoft.ML.OnnxRuntime.Gpu.Windows',
|
|
39
|
-
versions: metadataVersions.nuget,
|
|
40
|
-
},
|
|
41
|
-
'nuget:linux/x64:cuda12': {
|
|
42
|
-
name: 'Microsoft.ML.OnnxRuntime.Gpu.Linux',
|
|
43
|
-
versions: metadataVersions.nuget,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
feeds: {
|
|
47
|
-
nuget: {
|
|
48
|
-
type: 'nuget',
|
|
49
|
-
index: 'https://api.nuget.org/v3/index.json',
|
|
50
|
-
},
|
|
51
|
-
nuget_nightly: {
|
|
52
|
-
type: 'nuget',
|
|
53
|
-
index: 'https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
module.exports = metadata;
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const metadataVersions = require('./install-metadata-versions.js');
|
|
7
|
+
|
|
8
|
+
const metadata = {
|
|
9
|
+
// Requirements defines a list of manifest to install for a specific platform/architecture combination.
|
|
10
|
+
requirements: {
|
|
11
|
+
'win32/x64': [],
|
|
12
|
+
'win32/arm64': [],
|
|
13
|
+
'linux/x64': ['cuda12'],
|
|
14
|
+
'linux/arm64': [],
|
|
15
|
+
'darwin/x64': [],
|
|
16
|
+
'darwin/arm64': [],
|
|
17
|
+
},
|
|
18
|
+
// Each manifest defines a list of files to install
|
|
19
|
+
manifests: {
|
|
20
|
+
'linux/x64:cuda12': {
|
|
21
|
+
'./libonnxruntime_providers_cuda.so': {
|
|
22
|
+
package: 'nuget:linux/x64:cuda12',
|
|
23
|
+
path: 'runtimes/linux-x64/native/libonnxruntime_providers_cuda.so',
|
|
24
|
+
},
|
|
25
|
+
'./libonnxruntime_providers_shared.so': {
|
|
26
|
+
package: 'nuget:linux/x64:cuda12',
|
|
27
|
+
path: 'runtimes/linux-x64/native/libonnxruntime_providers_shared.so',
|
|
28
|
+
},
|
|
29
|
+
'./libonnxruntime_providers_tensorrt.so': {
|
|
30
|
+
package: 'nuget:linux/x64:cuda12',
|
|
31
|
+
path: 'runtimes/linux-x64/native/libonnxruntime_providers_tensorrt.so',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
// Each package defines a list of package metadata. The first available package will be used.
|
|
36
|
+
packages: {
|
|
37
|
+
'nuget:win32/x64:cuda12': {
|
|
38
|
+
name: 'Microsoft.ML.OnnxRuntime.Gpu.Windows',
|
|
39
|
+
versions: metadataVersions.nuget,
|
|
40
|
+
},
|
|
41
|
+
'nuget:linux/x64:cuda12': {
|
|
42
|
+
name: 'Microsoft.ML.OnnxRuntime.Gpu.Linux',
|
|
43
|
+
versions: metadataVersions.nuget,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
feeds: {
|
|
47
|
+
nuget: {
|
|
48
|
+
type: 'nuget',
|
|
49
|
+
index: 'https://api.nuget.org/v3/index.json',
|
|
50
|
+
},
|
|
51
|
+
nuget_nightly: {
|
|
52
|
+
type: 'nuget',
|
|
53
|
+
index: 'https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = metadata;
|