Failed to execute 'dispatch' on 'MLContext' after landing #45
Repro Steps A
- Enable WebNN in browser
- Visit https://microsoft.github.io/webnn-developer-preview/demos/image-classification/?provider=webnn&devicetype=gpu&model=mobilenet-v2&run=1
- Click "Classify" button
- It will show performance results, click "Classify" button again
Repro Steps B
- Enable WebNN in browser
- Visit https://microsoft.github.io/webnn-developer-preview/demos/image-classification/?provider=webnn&devicetype=gpu&model=mobilenet-v2&run=1
- Click "Classify" button
- It will show performance results, click "ResNet50" button
- Click "Classify" button
Actual Result
Failed to execute 'dispatch' on 'MLContext': Invalid inputs: The context of MLGraph doesn't match the context of the MLTensor with name "pixel_values".

@egalli do you have any clue to fix this issue, thanks!
CC @Honry @fdwr @huningxin
Note
This issue didn't occur by using compute() in ORT Web before.
How to build the Transformers.js dists and apply for developer preview image classification demo
- Clone https://github.com/xenova/transformers.js/tree/v3 // "onnxruntime-web": "1.20.0-dev.20241016-2b8fc5529b",
npm install
- Apply the patch https://github.com/ibelem/transformers.js/blob/v3-webnn-2/0001-v3-perf-code.patch or follow the code change in ibelem/transformers.js@7cb760f
npm run build
- Copy the dists from
/transformers.js/dist to webnn-developer-preview/assets/dist_transformers/dynamic-runs-1.19-dev/
Failed to execute 'dispatch' on 'MLContext' after landing #45
Repro Steps A
Repro Steps B
Actual Result
Failed to execute 'dispatch' on 'MLContext': Invalid inputs: The context of MLGraph doesn't match the context of the MLTensor with name "pixel_values".
@egalli do you have any clue to fix this issue, thanks!
CC @Honry @fdwr @huningxin
Note
This issue didn't occur by using compute() in ORT Web before.
How to build the Transformers.js dists and apply for developer preview image classification demo
npm installnpm run build/transformers.js/disttowebnn-developer-preview/assets/dist_transformers/dynamic-runs-1.19-dev/