-
Notifications
You must be signed in to change notification settings - Fork 937
ONNX Runtime improvements #1306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
xenova
wants to merge
17
commits into
main
Choose a base branch
from
ort-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
747a04d
ONNX Runtime improvements (experimental native webgpu; fix iOS) (#1231)
fs-eire bdaead0
customize the wasm paths (#1250)
fs-eire e025b7b
Merge branch 'main' into ort-improvements
xenova 573e5dc
[internal] Add is_decoder option to session retrieval for preferred o…
xenova 4d3a28d
Update tests
xenova 80f58ce
Formatting
xenova 071d728
Bump ort versions
xenova cfb8ff3
Bump onnxruntime-node version
xenova 7ea7718
Bump versions
xenova 2972828
Bump ORT versions
xenova ca9765c
Merge branch 'main' into ort-improvements
xenova ce7dfc0
Bump versions
xenova 87cdd0a
Only check webgpu fp16 for non-node environments
xenova 51c4bda
Fix
xenova 0f58976
Assume node supports webgpu
xenova 00f177b
Update ORT node support comment
xenova 11b59ed
Relax test strictness
xenova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ const DEVICE_TO_EXECUTION_PROVIDER_MAPPING = Object.freeze({ | |
webgpu: 'webgpu', // WebGPU | ||
cuda: 'cuda', // CUDA | ||
dml: 'dml', // DirectML | ||
coreml: 'coreml', // CoreML | ||
|
||
webnn: { name: 'webnn', deviceType: 'cpu' }, // WebNN (default) | ||
'webnn-npu': { name: 'webnn', deviceType: 'npu' }, // WebNN NPU | ||
|
@@ -63,13 +64,15 @@ if (ORT_SYMBOL in globalThis) { | |
} else if (apis.IS_NODE_ENV) { | ||
ONNX = ONNX_NODE.default ?? ONNX_NODE; | ||
|
||
// Updated as of ONNX Runtime 1.20.1 | ||
// Updated as of ONNX Runtime 1.23.0-dev.20250612-70f14d7670 | ||
// The following table lists the supported versions of ONNX Runtime Node.js binding provided with pre-built binaries. | ||
// | EPs/Platforms | Windows x64 | Windows arm64 | Linux x64 | Linux arm64 | MacOS x64 | MacOS arm64 | | ||
// | ------------- | ----------- | ------------- | ----------------- | ----------- | --------- | ----------- | | ||
// | CPU | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | ||
// | DirectML | ✔️ | ✔️ | ❌ | ❌ | ❌ | ❌ | | ||
// | CUDA | ❌ | ❌ | ✔️ (CUDA v11.8) | ❌ | ❌ | ❌ | | ||
// | EPs/Platforms | Windows x64 | Windows arm64 | Linux x64 | Linux arm64 | MacOS x64 | MacOS arm64 | | ||
// | --------------------- | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | | ||
// | CPU | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | ||
// | WebGPU (experimental) | ✔️ | ✔️ | ✔️ | ❌ | ✔️ | ✔️ | | ||
// | DirectML | ✔️ | ✔️ | ❌ | ❌ | ❌ | ❌ | | ||
// | CUDA | ❌ | ❌ | ✔️ (CUDA v12) | ❌ | ❌ | ❌ | | ||
// | CoreML | ❌ | ❌ | ❌ | ❌ | ✔️ | ✔️ | | ||
switch (process.platform) { | ||
case 'win32': // Windows x64 and Windows arm64 | ||
supportedDevices.push('dml'); | ||
|
@@ -80,9 +83,11 @@ if (ORT_SYMBOL in globalThis) { | |
} | ||
break; | ||
case 'darwin': // MacOS x64 and MacOS arm64 | ||
supportedDevices.push('coreml'); | ||
break; | ||
} | ||
|
||
supportedDevices.push('webgpu'); | ||
supportedDevices.push('cpu'); | ||
defaultDevices = ['cpu']; | ||
} else { | ||
|
@@ -180,9 +185,16 @@ if (ONNX_ENV?.wasm) { | |
if ( | ||
// @ts-ignore Cannot find name 'ServiceWorkerGlobalScope'.ts(2304) | ||
!(typeof ServiceWorkerGlobalScope !== 'undefined' && self instanceof ServiceWorkerGlobalScope) | ||
&& env.backends.onnx.versions?.web | ||
&& !ONNX_ENV.wasm.wasmPaths | ||
) { | ||
ONNX_ENV.wasm.wasmPaths = `https://cdn.jsdelivr.net/npm/@huggingface/transformers@${env.version}/dist/`; | ||
const wasmPathPrefix = `https://cdn.jsdelivr.net/npm/onnxruntime-web@${env.backends.onnx.versions.web}/dist/`; | ||
|
||
ONNX_ENV.wasm.wasmPaths = apis.IS_SAFARI ? { | ||
"mjs": `${wasmPathPrefix}/ort-wasm-simd-threaded.mjs`, | ||
"wasm": `${wasmPathPrefix}/ort-wasm-simd-threaded.wasm`, | ||
} | ||
: wasmPathPrefix; | ||
} | ||
|
||
// TODO: Add support for loading WASM files from cached buffer when we upgrade to [email protected] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be true for Bun, which does not have webgpu support.