From 8a06f13301d193cb1363f01be98e800079c541f4 Mon Sep 17 00:00:00 2001 From: Wanming Lin Date: Wed, 20 Nov 2024 02:22:02 +0800 Subject: [PATCH] [WebNN] Remove wasm.currentContext check (#22886) If a WebNN session is threw early, this check for `wasm.currentContext` will break all the following WebNN sessions, this often happens in npm tests. --- js/web/lib/wasm/wasm-core-impl.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/web/lib/wasm/wasm-core-impl.ts b/js/web/lib/wasm/wasm-core-impl.ts index f3794a72efbe8..81d1b73efc9d4 100644 --- a/js/web/lib/wasm/wasm-core-impl.ts +++ b/js/web/lib/wasm/wasm-core-impl.ts @@ -291,9 +291,6 @@ export const createSession = async ( const providerName = typeof provider === 'string' ? provider : provider.name; if (providerName === 'webnn') { wasm.shouldTransferToMLTensor = false; - if (wasm.currentContext) { - throw new Error('WebNN execution provider is already set.'); - } if (typeof provider !== 'string') { const webnnOptions = provider as InferenceSession.WebNNExecutionProviderOption; const context = (webnnOptions as InferenceSession.WebNNOptionsWithMLContext)?.context;