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.

wasm backend returns incorrect values as result

See original GitHub issue

I have a very simple float32 model (link provided in the code below) that takes image with values in range of 0…255 as input and returns a single float32 value.
Works perfectly with webgl backend, but values explode using wasm backend.
E.g., instead of returning value in range of 1-99, it returns values like 700+.

This is just one more case that looks like incorrect cast inside wasm backend, likely related to #4326 and #4311 that I’ve reported earlier.

simple reproduction code:

const resizeT = tf.image.resizeBilinear(image, [64, 64], false); // image is any picture of a face
const normalizeT = tf.mul(resizeT, [255.0]);
resizeT.dispose();
const model = await tf.loadGraphModel('https://vladmandic.github.io/human/models/age-ssrnet-imdb.json');
const ageT = await model.predict(normalizeT);
normalizeT.dispose();
const age = ageT.dataSync();
ageT.dispose();
console.log(age);

Environment: TFJS 2.8.3 on Chrome 87 / Windows 10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jinjingforevercommented, Feb 23, 2021

(sorry, I was on vacation last week)

Today we figured out that the error was caused by out-of-date xnnpack+emscripten. I am in the process of updating our toolchain to the latest xnnpack and emscripten. Hopefully it can be done this week. Thanks!

1reaction
jinjingforevercommented, Feb 12, 2021

BTW we further noticed that the wrong results come from some of the “div” nodes. With SIMD enabled, those nodes produce the results with the numerator and the denominator swapped… I am asking folks from the xnnpack project to investigate further. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

wasm backend is unusable for model training #4326
upgraded to tfjs 3.2.0 and confirmed as resolved - wasm backend now returns same results as webgl backend when used for model training....
Read more >
Wasm module exceeding maximum allowed functions
I changed the return values on create() and update() to include two function returns, and maybe that is what's causing it. No idea...
Read more >
Multi-Value All The Wasm!
Multi-value is a proposed extension to core WebAssembly that enables functions to return many values, among other things.
Read more >
Platform and environment | TensorFlow.js
WASM backend leverages the XNNPACK library for optimized implementation of neural network operators. Versus JavaScript: WASM binaries are ...
Read more >
Rasm: Compiling Racket to WebAssembly
Scheme compiler that is the backend of Racket. ... functions to convert returned WebAssembly values to their JavaScript ... incorrect parameter types.
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