-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Web] An error occurred during model execution: "TypeError: Cannot read properties of undefined (reading 'apply')". #15719
Comments
Here's a full demo which shows the problem. Just replace the first script link to your ort.js file and place your wasm files in the correct folder. <script src="http://localhost:8080/dist/ort.js"></script>
<script>
document.addEventListener('DOMContentLoaded', async () => {
// Load model
let url = 'https://huggingface.co/Xenova/bert-base-cased_web/resolve/main/onnx/model_quantized.onnx'
let model = await fetch(url);
let buffer = await model.arrayBuffer();
let array = new Uint8Array(buffer);
// Create a new session
let session = await ort.InferenceSession.create(array, {
executionProviders: ['wasm'],
})
// Construct model input
let input = {
attention_mask: new ort.Tensor(
'int64',
new BigInt64Array([1n, 1n, 1n, 1n, 1n, 1n, 1n, 1n, 1n]),
[1, 9],
),
input_ids: new ort.Tensor(
'int64',
// The goal of life is [MASK].
new BigInt64Array([101n, 1109n, 2273n, 1104n, 1297n, 1110n, 103n, 119n, 102n]),
[1, 9],
),
token_type_ids: new ort.Tensor(
'int64',
new BigInt64Array([0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n]),
[1, 9],
),
}
// Run the model with the input
let output = await session.run(input);
let logits = output.logits;
let [batchSize, sequenceLength, vocabSize] = logits.dims;
// Get logits of masked token
let maskIndex = 6;
let masked = logits.data.slice(maskIndex * vocabSize, (maskIndex + 1) * vocabSize);
let maxIndex = 0;
let maxValue = masked[0];
for (let i = 1; i < masked.length; ++i) {
if (masked[i] > maxValue) {
maxValue = masked[i];
maxIndex = i;
}
}
// Display output
// maxIndex === 8115, maxValue === 8.050320625305176
alert(`maxIndex=${maxIndex}, maxValue=${maxValue}`)
alert(`data=${logits.data.slice(0, 100)}`)
});
</script> produces: ort-wasm.js:28 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'apply')
at Ga (ort-wasm.js:28:361)
at ort-wasm-simd.wasm:0x8c2802
at Pa.b.<computed> (ort-wasm.js:38:150)
at c._OrtRun (ort-wasm.js:54:317)
at Object.run (wasm-core-impl.ts:213:28)
at run (proxy-wrapper.ts:221:17)
at OnnxruntimeWebAssemblySessionHandler.run (session-handler.ts:82:18)
at InferenceSession.run (inference-session-impl.js:91:1)
at HTMLDocument.<anonymous> (webgpu.html:39:28) |
I am aware of this issue. It might be a long story to explain... I will try to update with more info later. To workaround, disable SIMD and Threads:
and this unblocks you to try WebGPU EP. |
Okay - that made it work for WASM (albeit significantly slower). However, WebGPU didn't work due to the following issue:
I assume it's just an unsupported operation? |
I tried with a different model for image classification, and although it works, it is slower than the WASM implementation :/ WASM: 13807.7 milliseconds I assume that disabling SIMD has this effect? It also gives this warning:
|
a few tools that can be used to taking deeper look at it:
|
Great, thanks! Would you like me to run it and send the logs here? |
please send out logs - if model failed, or operator coverage issue, or bad performance, create new issues so that I can track them easier. |
here are the (very long) logs. I'm not too sure how to interpret it, but I can see that some of the later operations take like 2 seconds for some reason. |
Hi. Were you able to find the error? |
There are 3 issues that being discussed in this issue:
I tracked the later 2 issues in #15796 |
Okay great - thanks! I'll continue the conversation for the last 2 issues there. This issue can be closed when #15780 is merged. |
The PR is merged. |
Describe the issue
I am unable to use the latest build as the backend for Transformers.js due to the following error:
Unfortunately, it's quite difficult to tell what's going wrong as the minification doesn't help debugging.
To reproduce
Will throw the above error. It occurs for both WASM and WebGPU.
Urgency
Relatively urgent as - if this is a problem with the build itself - it will push back the webgpu release.
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
2efb75b
Execution Provider
WebGL, WASM, Other / Unknown
The text was updated successfully, but these errors were encountered: