Skip to content

Commit

Permalink
[js/webgpu] more fixes for access above 2GB (microsoft#19065)
Browse files Browse the repository at this point in the history
when jsep calls javascript with an index to HEAP8 or HEAP32 the index is
negative when the heap is above 2GB, even if we pass it as uint32_t it
remains negative. So in javascript use >>> 0 to make it unsigned.
  • Loading branch information
guschmue authored Jan 13, 2024
1 parent b1f258e commit 4457ced
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions web/lib/wasm/jsep/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const init = async(module: OrtWasmModule, env: Env, gpuAdapter: GPUAdapte
backend.memcpy(src, dst);
} else {
LOG_DEBUG('verbose', () => `[WebGPU] jsepCopyCpuToGpu: dataOffset=${src}, gpuDataId=${dst}, size=${size}`);
const data = module.HEAPU8.subarray(src, src + size);
const data = module.HEAPU8.subarray(src >>> 0, (src >>> 0) + size);
backend.upload(dst, data);
}
},
Expand All @@ -182,7 +182,8 @@ export const init = async(module: OrtWasmModule, env: Env, gpuAdapter: GPUAdapte
'verbose',
() => `[WebGPU] jsepCopyGpuToCpu: gpuDataId=${gpuDataId}, dataOffset=${dataOffset}, size=${size}`);

await backend.download(gpuDataId, () => module.HEAPU8.subarray(dataOffset, dataOffset + size));
await backend.download(
gpuDataId, () => module.HEAPU8.subarray(dataOffset >>> 0, (dataOffset >>> 0) + size));
},

// jsepCreateKernel
Expand Down

0 comments on commit 4457ced

Please sign in to comment.