Skip to content

Commit

Permalink
Fix isWebGPUSupported throwing an error in node (#8070)
Browse files Browse the repository at this point in the history
BUG
While node is not supported, 'isWebGPUSupported' should return false instead of
throwing an error. This fixes pose-detection node tests, which use the same
files as the browser tests.
mattsoulanille authored Nov 14, 2023
1 parent 7270e44 commit 0e50e74
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tfjs-backend-webgpu/src/webgpu_util.ts
Original file line number Diff line number Diff line change
@@ -155,7 +155,7 @@ export function GPUBytesPerElement(dtype: DataType): number {
}

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

export function assertNotComplex(

0 comments on commit 0e50e74

Please sign in to comment.