onnxruntime/js/web/lib/wasm
Enrico Galli df236c7894
[WebNN EP] Add cache for MLContexts in the WebNNBackend (#22510)
### Description
This change adds a cache of `MLContext`s keyed by their options to the
`WebNNBackend`. This makes is so that multiple `InferenceSession`s
create with the same options will share the same context.

### Motivation and Context
Since `MLTensor`s are tied `MLContext`s, developer can't easily share
tensors between `InferenceSession` (outside of manually an `MLContext`
and specifying the `context` options). This leads strange behaviors such
as,
```js
const sessionsA = ort.InferenceSession.create(urlA, {
  executionProviders: ["webnn"],
  preferredOutputLocation: "ml-buffer",
});
const sessionsB = ort.InferenceSession.create(urlB, {
  executionProviders: ["webnn"],
});
const temp = await sessionA.run({/* arguments */});
const result = await sessionB.run({"input":temp["output"]}); // ERROR: Failed to execute 'dispatch' on 'MLContext': Invalid inputs: The context of MLGraph doesn't match the context of the MLTensor with name "input".
```
We encountered this behavior when updating the transformers.js version
in the developer preview demos. microsoft/webnn-developer-preview#46
2024-10-30 10:26:33 -07:00
..
jsep [WebNN EP] Add cache for MLContexts in the WebNNBackend (#22510) 2024-10-30 10:26:33 -07:00
proxy-worker [js] change default formatter for JavaScript/TypeScript from clang-format to Prettier (#21728) 2024-08-14 16:51:22 -07:00
proxy-messages.ts [WebNN EP] Enable IO Bindings with MLTensor (#21301) 2024-09-27 17:24:21 -07:00
proxy-wrapper.ts [js] change default formatter for JavaScript/TypeScript from clang-format to Prettier (#21728) 2024-08-14 16:51:22 -07:00
run-options.ts [js] change default formatter for JavaScript/TypeScript from clang-format to Prettier (#21728) 2024-08-14 16:51:22 -07:00
session-handler-inference.ts [WebNN EP] Enable IO Bindings with MLTensor (#21301) 2024-09-27 17:24:21 -07:00
session-options.ts [JS/WebGPU] Support WASM64 (#21836) 2024-10-24 20:21:51 -07:00
wasm-common.ts [WebNN] Support int4 and uint4 data types (#22575) 2024-10-25 17:44:46 -07:00
wasm-core-impl.ts [WebNN EP] Add cache for MLContexts in the WebNNBackend (#22510) 2024-10-30 10:26:33 -07:00
wasm-factory.ts [js] change default formatter for JavaScript/TypeScript from clang-format to Prettier (#21728) 2024-08-14 16:51:22 -07:00
wasm-types.ts [WebNN EP] Add cache for MLContexts in the WebNNBackend (#22510) 2024-10-30 10:26:33 -07:00
wasm-utils-env.ts [js/web] optimize module export and deployment (#20165) 2024-05-20 09:51:16 -07:00
wasm-utils-import.ts [js/web] remove training release (#22103) 2024-09-16 10:56:22 -07:00
wasm-utils-load-file.ts [js] change default formatter for JavaScript/TypeScript from clang-format to Prettier (#21728) 2024-08-14 16:51:22 -07:00
wasm-utils.ts [JS/WebGPU] Support WASM64 (#21836) 2024-10-24 20:21:51 -07:00