Skip to content

Commit

Permalink
Fix webgpu support check failing if globalThis is undefined (#8073)
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 authored Nov 16, 2023
1 parent 5ad2606 commit 929b35d
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 929b35d

Please sign in to comment.