From 901c7de918e63a0c7f77cc0ecf3b4e12c969ad5d Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Thu, 14 Oct 2021 21:46:22 -0700 Subject: [PATCH] [js/web] remove webgl from default fallback list (#9374) --- js/common/lib/backend-impl.ts | 15 +++++++++------ js/web/lib/index.ts | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/js/common/lib/backend-impl.ts b/js/common/lib/backend-impl.ts index 1d6ea58ddd..518c573238 100644 --- a/js/common/lib/backend-impl.ts +++ b/js/common/lib/backend-impl.ts @@ -20,7 +20,8 @@ const backendsSortedByPriority: string[] = []; * * @param name - the name as a key to lookup as an execution provider. * @param backend - the backend object. - * @param priority - an integer indicating the priority of the backend. Higher number means higher priority. + * @param priority - an integer indicating the priority of the backend. Higher number means higher priority. if priority + * < 0, it will be considered as a 'beta' version and will not be used as a fallback backend by default. * * @internal */ @@ -35,13 +36,15 @@ export const registerBackend = (name: string, backend: Backend, priority: number throw new Error(`backend "${name}" is already registered`); } - for (let i = 0; i < backendsSortedByPriority.length; i++) { - if (backends[backendsSortedByPriority[i]].priority <= priority) { - backendsSortedByPriority.splice(i, 0, name); - return; + if (priority >= 0) { + for (let i = 0; i < backendsSortedByPriority.length; i++) { + if (backends[backendsSortedByPriority[i]].priority <= priority) { + backendsSortedByPriority.splice(i, 0, name); + return; + } } + backendsSortedByPriority.push(name); } - backendsSortedByPriority.push(name); return; } diff --git a/js/web/lib/index.ts b/js/web/lib/index.ts index ae0c747d70..970bd02fd3 100644 --- a/js/web/lib/index.ts +++ b/js/web/lib/index.ts @@ -6,5 +6,5 @@ import {registerBackend} from 'onnxruntime-common'; import {onnxjsBackend} from './backend-onnxjs'; import {wasmBackend} from './backend-wasm'; -registerBackend('webgl', onnxjsBackend, 1); -registerBackend('wasm', wasmBackend, 2); +registerBackend('webgl', onnxjsBackend, -1); +registerBackend('wasm', wasmBackend, 0);