Skip to content
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] TypeError: a.jsepAlloc is not a function #15832

Closed
nagadomi opened this issue May 6, 2023 · 3 comments · Fixed by #15851
Closed

[Web] TypeError: a.jsepAlloc is not a function #15832

nagadomi opened this issue May 6, 2023 · 3 comments · Fixed by #15851
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template

Comments

@nagadomi
Copy link

nagadomi commented May 6, 2023

Describe the issue

After #15796 (comment),
I tried WebGPU backend with the latest commit and got the following error:

bug.html:30 Uncaught (in promise) TypeError: a.jsepAlloc is not a function
    at 1597573 (blob:http://localhost:8812/5e8254b4-de81-4d27-b682-24214e1ce976:6:57758)
    at Di (blob:http://localhost:8812/5e8254b4-de81-4d27-b682-24214e1ce976:6:64218)
    at i.<computed> (blob:http://localhost:8812/5e8254b4-de81-4d27-b682-24214e1ce976:6:70382)
    at onnxruntime::js::JsCustomAllocator::Alloc(unsigned long) (ort-wasm-simd.jsep.wasm)
    at dynCall_iii (ort-wasm-simd.jsep.wasm)
    at e.<computed> (blob:http://localhost:8812/5e8254b4-de81-4d27-b682-24214e1ce976:6:70776)
    at blob:http://localhost:8812/5e8254b4-de81-4d27-b682-24214e1ce976:6:57368
    at invoke_iii (blob:http://localhost:8812/5e8254b4-de81-4d27-b682-24214e1ce976:6:83151)
    at i.<computed> (blob:http://localhost:8812/5e8254b4-de81-4d27-b682-24214e1ce976:6:70382)
    at onnxruntime::Tensor::Tensor(onnxruntime::DataTypeImpl const*, onnxruntime::TensorShape const&, std::__2::shared_ptr<onnxruntime::IAllocator>, gsl::span<long long const, 4294967295ul>) (ort-wasm-simd.jsep.wasm)

To reproduce

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <!-- <script src="//cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js"></script> -->
    <script src="dist/ort.webgpu.min.js"></script>
    <script>
     const BACKEND = "webgpu"; // wasm
     async function test_pad()
     {
       const ses = await ort.InferenceSession.create(
         "models/utils/pad.onnx",
         { executionProviders: [BACKEND] });
       const x = new ort.Tensor('float32', new Float32Array(3 * 32 * 32), [1, 3, 32, 32]);
       const left = new ort.Tensor('int64', BigInt64Array.from([4n]), []);
       const right = new ort.Tensor('int64', BigInt64Array.from([4n]), []);
       const top = new ort.Tensor('int64', BigInt64Array.from([4n]), []);
       const bottom = new ort.Tensor('int64', BigInt64Array.from([4n]), []);
       var out = await ses.run({
         "x": x,
         "left": left, "right": right,
         "top": top, "bottom": bottom});
       console.log(out.y.dims);
     }
     document.addEventListener("DOMContentLoaded", async function(event) { 
       console.log("load");
       ort.env.wasm.proxy = true;
       ort.env.wasm.simd = true;
       ort.env.wasm.numThreads = 1;
       await test_pad();
     });
    </script>
  </head>
  <body>
  </body>
</html>

pad.zip

I build and try it on Ubuntu.
build script gist

run Google Chrome 113.0.5672.63 with the following options.

google-chrome-stable --enable-unsafe-webgpu --enable-features=Vulkan

Urgency

No response

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

4145788

Execution Provider

Other / Unknown

@nagadomi nagadomi added the platform:web issues related to ONNX Runtime web; typically submitted using template label May 6, 2023
@fs-eire
Copy link
Contributor

fs-eire commented May 8, 2023

there are 2 problems here -

I got to this a.jsepAlloc is not a function issue last week, and it turns out the build steps are incorrect. could you try:

Another problem is that webgpu so far not working with ort.env.wasm.proxy = true;, and I am working on it. So not sure if this could be another reason for that error.

@nagadomi
Copy link
Author

nagadomi commented May 8, 2023

Another problem is that webgpu so far not working with ort.env.wasm.proxy = true;, and I am working on it. So not sure if this could be another reason for that error.

I tried ort.env.wasm.proxy = false; and it works without this error.
Also I downloaded NPM_packages.zip from CI and tried it and got the similar error when ort.env.wasm.proxy=true.

k @ b1058e05-f19b-4f08-b327-78a46bc3fb9d:6
bug.html:30 Uncaught (in promise) TypeError: t.Pa is not a function
    at 879093 (b1058e05-f19b-4f08-b327-78a46bc3fb9d:6:48234)
    at ee (b1058e05-f19b-4f08-b327-78a46bc3fb9d:6:52212)

So I think the issue is related to ort.env.wasm.proxy=true case.

@fs-eire
Copy link
Contributor

fs-eire commented May 8, 2023

I will work on supporting proxy for webgpu.

fs-eire added a commit that referenced this issue May 15, 2023
### Description
[js/webgpu] support proxy for webgpu. fixes #15832
prathikr pushed a commit that referenced this issue May 16, 2023
### Description
[js/webgpu] support proxy for webgpu. fixes #15832
siweic0 pushed a commit to siweic0/onnxruntime-web that referenced this issue May 9, 2024
### Description
[js/webgpu] support proxy for webgpu. fixes microsoft#15832
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants