[js/webgpu] only register webgpu backend when it's available (#15922)

### Description
only register webgpu backend when it's available
This commit is contained in:
Yulong Wang 2023-05-15 18:09:31 -07:00 committed by GitHub
parent dc383ed4ce
commit 22a9a1a630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,7 +16,7 @@ if (!BUILD_DEFS.DISABLE_WEBGL) {
if (!BUILD_DEFS.DISABLE_WASM) {
const wasmBackend = require('./backend-wasm').wasmBackend;
if (!BUILD_DEFS.DISABLE_WEBGPU) {
if (!BUILD_DEFS.DISABLE_WEBGPU && typeof navigator !== 'undefined' && navigator.gpu) {
registerBackend('webgpu', wasmBackend, 5);
}
registerBackend('cpu', wasmBackend, 10);