From 929b35db9553eeb339ab194e00103a5f8866c53c Mon Sep 17 00:00:00 2001 From: Matthew Soulanille Date: Thu, 16 Nov 2023 14:20:14 -0800 Subject: [PATCH] Fix webgpu support check failing if globalThis is undefined (#8073) Fix WebGPU support not working on iOS, where globalThis is sometimes not available. --- tfjs-backend-webgpu/src/webgpu_util.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tfjs-backend-webgpu/src/webgpu_util.ts b/tfjs-backend-webgpu/src/webgpu_util.ts index 0da772a8737..bf0f01d737d 100644 --- a/tfjs-backend-webgpu/src/webgpu_util.ts +++ b/tfjs-backend-webgpu/src/webgpu_util.ts @@ -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(