@omote/core 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2132,6 +2132,25 @@ async function isWebGPUAvailable() {
|
|
|
2132
2132
|
return false;
|
|
2133
2133
|
}
|
|
2134
2134
|
}
|
|
2135
|
+
var iosWasmPatched = false;
|
|
2136
|
+
function applyIOSWasmMemoryPatch() {
|
|
2137
|
+
if (iosWasmPatched || !isIOS()) return;
|
|
2138
|
+
iosWasmPatched = true;
|
|
2139
|
+
const OrigMemory = WebAssembly.Memory;
|
|
2140
|
+
const MAX_IOS_PAGES = 16384;
|
|
2141
|
+
logger.info("Applying iOS WASM memory patch (shared\u2192false, max\u21921GB)");
|
|
2142
|
+
WebAssembly.Memory = function IOSPatchedMemory(descriptor) {
|
|
2143
|
+
const patched = { ...descriptor };
|
|
2144
|
+
if (patched.shared) {
|
|
2145
|
+
patched.shared = false;
|
|
2146
|
+
}
|
|
2147
|
+
if (patched.maximum !== void 0 && patched.maximum > MAX_IOS_PAGES) {
|
|
2148
|
+
patched.maximum = MAX_IOS_PAGES;
|
|
2149
|
+
}
|
|
2150
|
+
return new OrigMemory(patched);
|
|
2151
|
+
};
|
|
2152
|
+
WebAssembly.Memory.prototype = OrigMemory.prototype;
|
|
2153
|
+
}
|
|
2135
2154
|
function configureWasm(ort) {
|
|
2136
2155
|
ort.env.wasm.wasmPaths = WASM_CDN_PATH;
|
|
2137
2156
|
const numThreads = getOptimalWasmThreads();
|
|
@@ -2157,6 +2176,7 @@ async function getOnnxRuntime(backend) {
|
|
|
2157
2176
|
return ortInstance;
|
|
2158
2177
|
}
|
|
2159
2178
|
logger.info(`Loading ONNX Runtime with ${backend} backend...`);
|
|
2179
|
+
applyIOSWasmMemoryPatch();
|
|
2160
2180
|
try {
|
|
2161
2181
|
if (backend === "wasm") {
|
|
2162
2182
|
const module = await import("onnxruntime-web");
|