-
Notifications
You must be signed in to change notification settings - Fork 928
fix package export #1161
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
Merged
Merged
fix package export #1161
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b4b0931
Upgrade package export
fs-eire 85bde32
set wasm path
fs-eire 1c19e5e
Merge remote-tracking branch 'origin/main' into fix-export
fs-eire b352705
Update default wasmPaths URL
xenova 9ecfe9b
Bump versions
xenova a2bf77c
Set version correctly for separate PR
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
|
@@ -57,8 +57,8 @@ let ONNX; | |
const ORT_SYMBOL = Symbol.for('onnxruntime'); | ||
|
||
if (ORT_SYMBOL in globalThis) { | ||
// If the JS runtime exposes their own ONNX runtime, use it | ||
ONNX = globalThis[ORT_SYMBOL]; | ||
// If the JS runtime exposes their own ONNX runtime, use it | ||
ONNX = globalThis[ORT_SYMBOL]; | ||
|
||
} else if (apis.IS_NODE_ENV) { | ||
ONNX = ONNX_NODE.default ?? ONNX_NODE; | ||
|
@@ -175,23 +175,27 @@ const ONNX_ENV = ONNX?.env; | |
if (ONNX_ENV?.wasm) { | ||
// Initialize wasm backend with suitable default settings. | ||
|
||
// (Optional) Set path to wasm files. This is needed when running in a web worker. | ||
// https://onnxruntime.ai/docs/api/js/interfaces/Env.WebAssemblyFlags.html#wasmPaths | ||
// We use remote wasm files by default to make it easier for newer users. | ||
// In practice, users should probably self-host the necessary .wasm files. | ||
ONNX_ENV.wasm.wasmPaths = `https://cdn.jsdelivr.net/npm/@huggingface/transformers@${env.version}/dist/`; | ||
// (Optional) Set path to wasm files. This will override the default path search behavior of onnxruntime-web. | ||
// Currently, this behavior is disabled. To enable it, uncomment the following code. | ||
|
||
// // Override the wasm search path if: | ||
// // 1. We are not in a service worker. | ||
// // 2. ONNX Runtime Web version is defined. | ||
// // 3. The wasmPaths are not already set. | ||
// // | ||
// // @ts-ignore Cannot find name 'ServiceWorkerGlobalScope'.ts(2304) | ||
// if (!(typeof ServiceWorkerGlobalScope !== 'undefined' && self instanceof ServiceWorkerGlobalScope) | ||
// && typeof ONNX?.versions?.web === 'string' | ||
// && !ONNX_ENV.wasm.wasmPaths) { | ||
// ONNX_ENV.wasm.wasmPaths = `https://cdn.jsdelivr.net/npm/onnxruntime-web@${ONNX.versions.web}/dist/`; | ||
// } | ||
|
||
// TODO: Add support for loading WASM files from cached buffer when we upgrade to [email protected] | ||
// https://github.com/microsoft/onnxruntime/pull/21534 | ||
|
||
// Users may wish to proxy the WASM backend to prevent the UI from freezing, | ||
// However, this is not necessary when using WebGPU, so we default to false. | ||
ONNX_ENV.wasm.proxy = false; | ||
|
||
// https://developer.mozilla.org/en-US/docs/Web/API/crossOriginIsolated | ||
if (typeof crossOriginIsolated === 'undefined' || !crossOriginIsolated) { | ||
ONNX_ENV.wasm.numThreads = 1; | ||
} | ||
xenova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
if (ONNX_ENV?.webgpu) { | ||
|
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
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.
Uh oh!
There was an error while loading. Please reload this page.