File tree Expand file tree Collapse file tree 4 files changed +10
-1
lines changed Expand file tree Collapse file tree 4 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import { env, apis } from '../env.js';
21
21
// NOTE: Import order matters here. We need to import `onnxruntime-node` before `onnxruntime-web`.
22
22
// In either case, we select the default export if it exists, otherwise we use the named export.
23
23
import * as ONNX_NODE from 'onnxruntime-node' ;
24
- import * as ONNX_WEB from 'onnxruntime-web/webgpu ' ;
24
+ import * as ONNX_WEB from 'onnxruntime-web/all ' ;
25
25
26
26
export { Tensor } from 'onnxruntime-common' ;
27
27
@@ -68,6 +68,9 @@ if (apis.IS_NODE_ENV) {
68
68
if ( apis . IS_WEBGPU_AVAILABLE ) {
69
69
supportedExecutionProviders . push ( 'webgpu' ) ;
70
70
}
71
+ if ( apis . IS_WEBNN_AVAILABLE ) {
72
+ supportedExecutionProviders . push ( 'webnn' ) ;
73
+ }
71
74
supportedExecutionProviders . push ( 'wasm' ) ;
72
75
defaultExecutionProviders = [ 'wasm' ] ;
73
76
}
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ const IS_BROWSER_ENV = typeof self !== 'undefined';
33
33
const IS_WEBWORKER_ENV = IS_BROWSER_ENV && self . constructor . name === 'DedicatedWorkerGlobalScope' ;
34
34
const IS_WEB_CACHE_AVAILABLE = IS_BROWSER_ENV && 'caches' in self ;
35
35
const IS_WEBGPU_AVAILABLE = typeof navigator !== 'undefined' && 'gpu' in navigator ;
36
+ const IS_WEBNN_AVAILABLE = typeof navigator !== 'undefined' && 'ml' in navigator ;
36
37
37
38
const IS_PROCESS_AVAILABLE = typeof process !== 'undefined' ;
38
39
const IS_NODE_ENV = IS_PROCESS_AVAILABLE && process ?. release ?. name === 'node' ;
@@ -55,6 +56,9 @@ export const apis = Object.freeze({
55
56
/** Whether the WebGPU API is available */
56
57
IS_WEBGPU_AVAILABLE ,
57
58
59
+ /** Whether the WebNN API is available */
60
+ IS_WEBNN_AVAILABLE ,
61
+
58
62
/** Whether the Node.js process API is available */
59
63
IS_PROCESS_AVAILABLE ,
60
64
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export const DEVICE_TYPES = Object.freeze({
8
8
cpu : 'cpu' , // CPU
9
9
wasm : 'wasm' , // WebAssembly
10
10
webgpu : 'webgpu' , // WebGPU
11
+ webnn : 'webnn' , // WebNN
11
12
cuda : 'cuda' , // CUDA
12
13
dml : 'dml' , // DirectML
13
14
} ) ;
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ export const DEFAULT_DEVICE_DTYPE_MAPPING = Object.freeze({
47
47
[ DEVICE_TYPES . gpu ] : DATA_TYPES . fp32 ,
48
48
[ DEVICE_TYPES . wasm ] : DATA_TYPES . q8 ,
49
49
[ DEVICE_TYPES . webgpu ] : DATA_TYPES . fp32 ,
50
+ [ DEVICE_TYPES . webnn ] : DATA_TYPES . fp32 ,
50
51
[ DEVICE_TYPES . cuda ] : DATA_TYPES . fp32 ,
51
52
[ DEVICE_TYPES . dml ] : DATA_TYPES . fp32 ,
52
53
} ) ;
You can’t perform that action at this time.
0 commit comments