WASM backend: cast to bool, conv2d/maxPool3d with pad "same", and oneHot with float values disagree with the CPU backend
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 28/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- cpp, javascript, typescript, wasm
- Área
- backend, machine-learning
Línea de trabajo
Four separate wasm kernels are involved: kernels/Cast.ts for the bool cast, the conv2d and depthwiseConv2d SAME-padding path that goes through XNNPACK, MaxPool3D.cc and MaxPoolWithArgmax.cc for the initial max value, and OneHot.cc for the on/off value types. Run the repro snippets with node repro.js cpu and node repro.js wasm to confirm each mismatch. Done means every wasm output matches the cpu backend for those cases.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Four wasm-backend kernels give different results from the cpu backend.
System information
- Custom code: yes
- OS: Linux x86_64 (Debian 12)
- TensorFlow.js installed from: npm
- Version: @tensorflow/tfjs 4.22.0, @tensorflow/tfjs-backend-wasm 4.22.0, Node 20.20.2
All snippets use this header and run as node repro.js cpu and node repro.js wasm:
const tf = require('@tensorflow/tfjs')
require('@tensorflow/tfjs-backend-wasm')
const show = (t) => console.log(Array.from(t.dataSync()))
;(async () => { await tf.setBackend(process.argv[2]); await tf.ready()
// case code here
})()
1. cast to bool truncates instead of testing for non-zero
show(tf.cast(tf.tensor1d([0.5, 2, 256, Infinity, NaN, 0]), 'bool'))
show(tf.cast(tf.tensor1d([1, 2, 256, 0], 'int32'), 'bool'))
wasm: [0, 2, 0, 0, 0, 0] and [1, 2, 0, 0]
cpu: [1, 1, 1, 1, 1, 0] and [1, 1, 1, 0]
kernels/Cast.ts does outVals.set(inVals) into a Uint8Array.
2. conv2d / depthwiseConv2d with pad 'same' return zeros when the filter is smaller than the stride
const x = tf.tensor4d([1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 4, 1])
const f = tf.tensor4d([1, 1, 1], [1, 3, 1, 1])
show(tf.conv2d(x, f, 2, 'same'))
show(tf.depthwiseConv2d(x, f, 2, 'same'))
wasm: [0, 0] and [0, 0]
cpu: [6, 7] and [6, 7]
The total SAME padding here is -1. The pinned XNNPACK computes it as an unsigned size_t without clamping at 0.
3. maxPool3d / maxPoolWithArgmax return 1.17e-38 when the whole window is negative
show(tf.maxPool3d(tf.tensor5d([-1, -2, -3, -4], [1, 1, 2, 2, 1]), [1, 2, 2], 1, 'valid'))
show(tf.maxPoolWithArgmax(tf.tensor4d([-1, -2, -3, -4], [1, 2, 2, 1]), 2, 1, 'valid').result)
wasm: [1.1754943508222875e-38] and [1.1754943508222875e-38]
cpu: [-1] and [-1]
MaxPool3D.cc and MaxPoolWithArgmax.cc start from std::numeric_limits<float>::min() instead of lowest().
4. oneHot with float32 output ignores fractional on/off values
show(tf.oneHot(tf.tensor1d([0, 2], 'int32'), 3, 0.5, 0.25, 'float32'))
show(tf.oneHot(tf.tensor1d([0, 2], 'int32'), 3, 1, -1, 'float32'))
wasm: [0, 0, 0, 0, 0, 0] and [1.401298464324817e-45, NaN, NaN, NaN, NaN, 1.401298464324817e-45]
cpu: [0.5, 0.25, 0.25, 0.25, 0.25, 0.5] and [1, -1, -1, -1, -1, 1]
OneHot.cc takes int32_t on/off values and always writes through i32_write().
Found with a differential-testing tool; the report was drafted with AI assistance and reviewed and edited by me.
Credit: https://ucsbplse.github.io/
- Lenguaje dominante
- TypeScript
- Estrellas
- 19.2k
- Forks
- 2k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de tensorflow/tfjs
-
[CPU] ResizeBilinearGrad swaps height and width for rectangular inputs in TensorFlow.js 4.22.0Posiblemente ocupada @nileshau-afk la tomó hace 1 día. Abiertocomp:backend-cpu type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
tensorflow/tfjs#8757 · 1 asignado ·
-
conv3d, maxPool3d and avgPool3d with pad 'same' use the wrong window when the filter is smaller than the stridePosiblemente ocupada @nileshau-afk la tomó hace 1 día. Abiertocomp:core type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
tensorflow/tfjs#8753 · 1 asignado ·
-
tf.stridedSlice returns wrong values or throws when shrinkAxisMask is combined with a non-unit stride on another axisPosiblemente ocupada @nileshau-afk la tomó hace 1 día. Abiertocomp:backend-cpu comp:core type:bug
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
tensorflow/tfjs#8756 · 1 asignado ·
-
Review argparse dependency bringing in sprintf-js CVE-2026-97058Posiblemente ocupada @Varun-S10 la tomó hace 22 días. Abiertotype:others type:support
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
tensorflow/tfjs#8749 · 1 asignado ·
-
`@tensorflow/tfjs-node` installation issueQuizá libre de nuevo @nileshau-afk la tomó hace 32 días y no hay ningún pull request abierto. Abiertocomp:node.js type:build/install
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
tensorflow/tfjs#8748 · 1 asignado ·
Todos los issues de tensorflow/tfjs
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
mcp: create_app refuses the Assistant Inbox spec as 'looks like an API key' (nesting deeper than 8)Abiertoagent:claude agent:ready dogfood type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
opennextjs/opennextjs-cloudflare#1485 ·
Los mantenedores suelen responder en 1 día
-
enhancement lane: fast tier: should-stable
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
unicef/adt-studio#1078 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
WenyuChiou/agent-board#1283 ·
Los mantenedores suelen responder en 1 día