71 lines
3.0 KiB
Diff
71 lines
3.0 KiB
Diff
diff --git a/dist/transformers.web.js b/dist/transformers.web.js
|
|
index a86f15e936b5b03d960037ed3e82a175dd5a0ffb..d74ef622704370b0235a628cfa5746b06fcc620e 100644
|
|
--- a/dist/transformers.web.js
|
|
+++ b/dist/transformers.web.js
|
|
@@ -19840,22 +19840,49 @@ async function getSession(pretrained_model_name_or_path, fileName, options, cach
|
|
return { buffer_or_path, session_options, session_config };
|
|
}
|
|
async function constructSessions(pretrained_model_name_or_path, names, options, cache_sessions = void 0) {
|
|
- return Object.fromEntries(
|
|
- await Promise.all(
|
|
- Object.keys(names).map(async (name) => {
|
|
- const cache_config = cache_sessions?.[name] ?? false;
|
|
- const { buffer_or_path, session_options, session_config } = await getSession(
|
|
- pretrained_model_name_or_path,
|
|
- names[name],
|
|
- options,
|
|
- cache_config,
|
|
- name
|
|
- );
|
|
- const session = await createInferenceSession(buffer_or_path, session_options, session_config);
|
|
- return [name, session];
|
|
- })
|
|
- )
|
|
- );
|
|
+ // Patched (whisper_web): each entry briefly holds a full-size decoded
|
|
+ // model buffer in JS-heap memory (on top of onnxruntime-web's own WASM-heap
|
|
+ // copy during session creation); loading Whisper's encoder and decoder
|
|
+ // concurrently keeps both buffers alive at once and roughly doubles the
|
|
+ // load-time memory peak, which is enough to OOM-crash mobile browsers on
|
|
+ // larger models (e.g. medium, ~460 MB combined). `options.sequentialSessionLoad`
|
|
+ // (set by the caller only when that risk is real, D-027/D-029) loads
|
|
+ // sub-model sessions one at a time instead of Promise.all-ing them, so the
|
|
+ // previous entry's buffer becomes garbage before the next one is fetched —
|
|
+ // at the cost of losing the download concurrency a fast connection could
|
|
+ // otherwise use, which is the default (and always was, pre-D-027).
|
|
+ if (!options?.sequentialSessionLoad) {
|
|
+ return Object.fromEntries(
|
|
+ await Promise.all(
|
|
+ Object.keys(names).map(async (name) => {
|
|
+ const cache_config = cache_sessions?.[name] ?? false;
|
|
+ const { buffer_or_path, session_options, session_config } = await getSession(
|
|
+ pretrained_model_name_or_path,
|
|
+ names[name],
|
|
+ options,
|
|
+ cache_config,
|
|
+ name
|
|
+ );
|
|
+ const session = await createInferenceSession(buffer_or_path, session_options, session_config);
|
|
+ return [name, session];
|
|
+ })
|
|
+ )
|
|
+ );
|
|
+ }
|
|
+ const entries = [];
|
|
+ for (const name of Object.keys(names)) {
|
|
+ const cache_config = cache_sessions?.[name] ?? false;
|
|
+ const { buffer_or_path, session_options, session_config } = await getSession(
|
|
+ pretrained_model_name_or_path,
|
|
+ names[name],
|
|
+ options,
|
|
+ cache_config,
|
|
+ name
|
|
+ );
|
|
+ const session = await createInferenceSession(buffer_or_path, session_options, session_config);
|
|
+ entries.push([name, session]);
|
|
+ }
|
|
+ return Object.fromEntries(entries);
|
|
}
|
|
function replaceTensors(obj) {
|
|
for (let prop in obj) {
|