50 lines
2.2 KiB
Diff
50 lines
2.2 KiB
Diff
diff --git a/dist/transformers.web.js b/dist/transformers.web.js
|
|
index bb7b32717a42475a5f66411a33d5e5964dfda3e2..799cb402e98d8d0d58bf59629c4c2992407477e0 100644
|
|
--- a/dist/transformers.web.js
|
|
+++ b/dist/transformers.web.js
|
|
@@ -18558,22 +18558,28 @@ 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 (au_whisper_web): load sub-model sessions one at a time instead of
|
|
+ // Promise.all-ing them. 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). Sequential loading lets the
|
|
+ // previous entry's buffer become garbage before the next one is fetched.
|
|
+ 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) {
|