mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-17 21:10:43 +00:00
[js/web] allow proxy to load model with 1GB <= size < 2GB (#19178)
### Description allow proxy to load model with 1GB <= size < 2GB resolves #19157.
This commit is contained in:
parent
bc219ed553
commit
146ebaf91e
1 changed files with 13 additions and 3 deletions
|
|
@ -47,9 +47,19 @@ export const loadFile = async(file: string|Blob|ArrayBufferLike|Uint8Array): Pro
|
|||
}
|
||||
const reader = response.body.getReader();
|
||||
|
||||
// use WebAssembly Memory to allocate larger ArrayBuffer
|
||||
const pages = Math.ceil(fileSize / 65536);
|
||||
const buffer = new WebAssembly.Memory({initial: pages, maximum: pages}).buffer;
|
||||
let buffer;
|
||||
try {
|
||||
// try to create ArrayBuffer directly
|
||||
buffer = new ArrayBuffer(fileSize);
|
||||
} catch (e) {
|
||||
if (e instanceof RangeError) {
|
||||
// use WebAssembly Memory to allocate larger ArrayBuffer
|
||||
const pages = Math.ceil(fileSize / 65536);
|
||||
buffer = new WebAssembly.Memory({initial: pages, maximum: pages}).buffer;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
let offset = 0;
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
|
|
|
|||
Loading…
Reference in a new issue