question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FaceDetection is not working on wasm backend

See original GitHub issue

Hi everyone, first of all, thanks for this excellent library! I ran into an issue while trying to run FaceDetection or FaceLandmarksDetection models on the wasm backend.

Describe the current behavior While this works well on WebGL backend, when I use the wasm backend, I get either empty array as a result or a memory access out of bounds (might be related to #6128)

RuntimeError: memory access out of bounds
    at tfjs-backend-wasm-simd.wasm:0x3ff23
    at tfjs-backend-wasm-simd.wasm:0x2cdc7
    at tfjs-backend-wasm-simd.wasm:0x2dacd
    at tfjs-backend-wasm-simd.wasm:0x1d5d9
    at tfjs-backend-wasm-simd.wasm:0x68da
    at Module._FusedConv2D (tfjs-backend-wasm.js:9:21945)
    at Object.fusedConv2d [as kernelFunc] (FusedConv2D.ts:140:3)
    at kernelFunc (engine.ts:644:22)
    at engine.ts:710:23
    at Engine.scopedRun (engine.ts:478:19)

You can find code sandbox examples with WebGL and wasm below. I also tried this stock example provided by TensorFlow.js by adding tfjs-wasm in the list of model backends, but I get the same issue with nothing detected at all (empty array)

Is there something I am missing or doing wrong here?

Thanks for your help!

Describe the expected behavior I guess the expected behavior is that it works on both wasm and WebGL backend.

Standalone code to reproduce the issue Example with wasm backend: https://codesandbox.io/s/confident-nightingale-b8z48b Example with WebGL backend: https://codesandbox.io/s/elegant-tereshkova-mdqj6k

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS Monterey
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: Pixel 4a
  • TensorFlow.js installed from (npm or script link): npm
  • TensorFlow.js version (use command below): 3.18.0
  • Browser version: Chrome 102.0.5005.61
  • Tensorflow.js Converter Version: 3.18.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mattsoulanillecommented, Jun 21, 2022

Quick update to this issue: I built the WASM backend with debug flags set, and here’s its more descriptive error message. Thanks for posting a reproduction!

RuntimeError: memory access out of bounds
    at xnn_f32_igemm_relu_ukernel_4x8__wasmsimd_splat (tfjs-backend-wasm-simd.wasm:0x1608e4)
    at xnn_compute_igemm (tfjs-backend-wasm-simd.wasm:0xd29af)
    at pthreadpool_parallelize_2d_tile_2d (tfjs-backend-wasm-simd.wasm:0x1dc567)
    at xnn_run_operator (tfjs-backend-wasm-simd.wasm:0xd58b0)
    at tfjs::wasm::conv2d(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, bool, FusableActivation, unsigned long, float, unsigned long) (tfjs-backend-wasm-simd.wasm:0x600e9)
    at FusedConv2D (tfjs-backend-wasm-simd.wasm:0x2a2e0)
    at tfjs-backend-wasm.js:2176:1
    at ccall (tfjs-backend-wasm.js:1368:1)
    at tfjs-backend-wasm.js:1383:1
    at Object.fusedConv2d [as kernelFunc] (FusedConv2D.ts:140:1)
0reactions
google-ml-butler[bot]commented, Sep 21, 2022

Are you satisfied with the resolution of your issue? Yes No

Read more comments on GitHub >

github_iconTop Results From Across the Web

WASM backend stopped working In the latest Chrome (macOS)
System information. Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): No.
Read more >
WASM backend for tensorflowjs throws "Unhandled Rejection ...
Save this question. Show activity on this post. I am trying to set up a WASM back-end for blazeface face detection model in...
Read more >
@tensorflow/tfjs-backend-wasm - npm
Face detector is a lite model with 0.1M params and ~20M multiply-adds. For this model, the WASM backend is between ~8.2-19.8X faster than...
Read more >
Pigo, the face detection library has been ported to WASM ...
No, I haven't tried it, but right now i'm not too concerned about the generated wasm binary file size, more about the cascade...
Read more >
Porting a Go-Based Face Detection Library to Wasm - InfoQ
Endre Simo has recently ported the Pigo face detection library from the Go runtime to web browsers using WebAssembly.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found