diff --git a/js/web/lib/wasm/jsep/backend-webgpu.ts b/js/web/lib/wasm/jsep/backend-webgpu.ts index 4b544595d76bb..98990a6fe477b 100644 --- a/js/web/lib/wasm/jsep/backend-webgpu.ts +++ b/js/web/lib/wasm/jsep/backend-webgpu.ts @@ -530,8 +530,10 @@ export class WebGpuBackend { }; this.pendingKernels.push(pendingKernelInfo); - const sessionPendingKernels = this.capturedPendingKernels.get(this.currentSessionId!); - sessionPendingKernels!.push(pendingKernelInfo); + if (this.sessionStatus === 'capturing') { + const sessionPendingKernels = this.capturedPendingKernels.get(this.currentSessionId!); + sessionPendingKernels!.push(pendingKernelInfo); + } } this.programManager.run(artifact, inputDatas, outputDatas, normalizedDispatchGroup, uniformBufferBinding);