[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.
This commit is contained in:
Wanming Lin 2024-11-20 02:22:02 +08:00 committed by GitHub
parent 0d00fc3130
commit 8a06f13301
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;