From 8767f3f883ee6061e461fd13e51d3d3e1abb64d3 Mon Sep 17 00:00:00 2001 From: Wanming Lin Date: Tue, 19 Nov 2024 16:20:56 +0800 Subject: [PATCH] [WebNN] Remove wasm.currentContext check If a WebNN session is thrown 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;