Skip to content

Commit

Permalink
Fix webgpu support check failing if globalThis is undefined
Browse files Browse the repository at this point in the history
Fix WebGPU support not working on iOS, where globalThis is sometimes not
available.
  • Loading branch information
mattsoulanille committed Nov 16, 2023
1 parent 5ad2606 commit 773a26f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tfjs-backend-webgpu/src/webgpu_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export function GPUBytesPerElement(dtype: DataType): number {
}

export function isWebGPUSupported(): boolean {
return !!(globalThis && (globalThis.navigator) && (globalThis.navigator.gpu));
return !!(typeof globalThis !== 'undefined' && (globalThis.navigator)
&& (globalThis.navigator.gpu));
}

export function assertNotComplex(
Expand Down

0 comments on commit 773a26f

Please sign in to comment.