[js/webgpu] Fix the undefined push error (#19366)

### Description
This PR fixes below errors when enable webgpu profiling: 
```
TypeError: Cannot read properties of undefined (reading 'push')
```
This commit is contained in:
Jiajia Qin 2024-02-02 18:04:06 +08:00 committed by GitHub
parent 9139bdda02
commit efc17e79de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);