From ebe715a8172b132c3ae577b79604c04b45a3dccb Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Tue, 30 May 2023 15:04:50 -0700 Subject: [PATCH] [js/webgpu] fix RangeError in buffer download (#16165) ### Description this is a following up fix for #15990, which should resolve the RangeError issue. --- js/web/lib/wasm/jsep/backend-webgpu.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/web/lib/wasm/jsep/backend-webgpu.ts b/js/web/lib/wasm/jsep/backend-webgpu.ts index 12a5cd48b1..8aa825abfb 100644 --- a/js/web/lib/wasm/jsep/backend-webgpu.ts +++ b/js/web/lib/wasm/jsep/backend-webgpu.ts @@ -289,7 +289,7 @@ export class WebGpuBackend { // the underlying buffer may be changed after the async function is called. so we use a getter function to make sure // the buffer is up-to-date. const data = getTargetBuffer(); - data.set(new Uint8Array(arrayBuffer)); + data.set(new Uint8Array(arrayBuffer, 0, data.byteLength)); } alloc(size: number): number {