[CPU] ResizeBilinearGrad swaps height and width for rectangular inputs in TensorFlow.js 4.22.0
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 77/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, node.js, typescript
- Lĩnh vực
- backend, machine-learning, testing
Hướng nghiên cứu
Đọc tfjs-backend-cpu/src/kernels/ResizeBilinearGrad.ts và kiểm tra hình dạng đầu ra mà kernel gradient CPU trả về. Bắt đầu với bản tái hiện tối thiểu được cung cấp trong scripts/diagnostics/tfjs-resize-minimal.mjs; bổ sung kiểm thử hồi quy cho đầu vào hình chữ nhật rank 3 và rank 4, cả hai thiết lập align-corners, cùng số lượng batch và kênh đa dạng. Hoàn tất khi autodiff CPU trả về hình dạng đầu vào và các trường hợp hồi quy đều vượt qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
CPU ResizeBilinearGrad swaps height and width for rectangular inputs (TensorFlow.js 4.22.0)
Prepared 2026-11-08. This report contains synthetic tensors only; no application
models, photograph data, account information or credentials are required.
Environment
@tensorflow/tfjs: 4.22.0, including CPU/WebGL backends 4.22.0.- Windows x64; Node.js v24.21.0.
- Independently reproduced in headless Microsoft Edge 157.0.0.0 on Windows.
- WebGL comparison renderer: Intel HD Graphics 620 through ANGLE / Direct3D11.
- Pure JavaScript CPU backend, not
@tensorflow/tfjs-node.
Minimal reproduction
In an otherwise empty directory, install @tensorflow/[email protected], save the
following as repro.mjs, then run node repro.mjs:
import * as tf from '@tensorflow/tfjs';
await tf.setBackend('cpu');
await tf.ready();
tf.tidy(() => {
const x = tf.ones([1, 2, 3, 1]);
console.log(tf.image.resizeBilinear(x, [4, 5], true).shape);
const gradient = tf.grad(
image => tf.image.resizeBilinear(image, [4, 5], true).sum()
)(x);
console.log(gradient.shape);
});
Expected: forward shape [1,4,5,1]; gradient shape [1,2,3,1].
Actual: forward succeeds, then autodiff throws:
Error in gradient for op ResizeBilinear. The gradient of input 'images' has
shape '1,3,2,1', which does not match the shape of the input '1,2,3,1'
The same failure occurs for a portrait input [512,384,3] resized to [224,224]:
the internal gradient shape is [1,384,512,3] instead of [1,512,384,3].
Test matrix
The same 16 forward/autodiff cases were tested independently in each environment:
eight input shapes, each with alignCorners=false and alignCorners=true.
Input shapes:
[2,3,1], [3,2,1], [3,3,1], [1,2,3,1], [2,2,3,2],
[512,384,3], [384,512,3], [224,224,3]
Large rectangular inputs were resized to [224,224]; other inputs to [4,5].
Both channels and batch size vary in these checks.
| Environment/backend | Square gradients pass | Rectangular gradients fail | Forward failures |
|---|---|---|---|
| Node / CPU | 4 | 12 | 0 |
| Edge / CPU | 4 | 12 | 0 |
| Edge / WebGL | 4 | 0 (all 12 pass) | 0 |
All successful gradients had the expected input shape and finite values.
This is not a claim about every browser, graphics driver or other backend.
Numerical check and suspected cause
The installed CPU kernel ends with:
return backend.makeTensorInfo([batch, xWidth, xHeight, depth], 'float32', output);
Its input unpacking and accumulation indexing use NHWC with height before width.
The suspected correction is the output shape:
- [batch, xWidth, xHeight, depth]
+ [batch, xHeight, xWidth, depth]
To distinguish a shape problem from incorrect derivative values, the diagnostic
also directly evaluates the raw ResizeBilinearGrad kernel (without changing or
registering any kernels) and compares its flattened values against central
finite differences of a nonuniform weighted sum of the forward resize.
- Shapes:
[1,2,3,1],[1,3,3,1],[2,2,3,2]. - Both align-corners settings; all input coordinates checked.
- Central-difference epsilon: 0.001.
- Maximum absolute discrepancy, Node CPU and Edge CPU: 0.00002975762.
- Maximum absolute discrepancy, Edge WebGL: 0.00005230308.
This supports an output-shape metadata error for the tested settings. Simply
reshaping the result at application level cannot repair normal tf.grad,
because its shape check throws before returning that result.
No dependency patch has been applied. Proposed upstream regression tests should
cover rectangular rank-3/rank-4 inputs, multiple batches/channels, both
align-corners settings, and comparison against numerical gradients.
Scope
Forward image resizing works in these cases. The failure concerns CPU autodiff
through bilinear resize with rectangular inputs. No pretrained network or
application-specific code is involved.
The diagnostic files in this workspace are:
scripts/diagnostics/tfjs-resize-minimal.mjs: standalone minimal reproduction.scripts/diagnostics/tfjs-resize-gradient.mjs: expanded Node/Edge checks.test-data.local/tfjs-resize-gradient/results.json: recorded detailed results.
The expanded runner requires the existing Playwright/Edge installation. The
minimal reproduction requires only TensorFlow.js.
Upstream reporting
Intended tracker: https://github.com/tensorflow/tfjs/issues
The public source page inspected also contains the same swapped expression:
https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-cpu/src/kernels/ResizeBilinearGrad.ts
The GitHub commits API queried on 2026-11-08 identifies the latest commit touching
that file as 087a02a2848db8ba1950c6894fc76d8be3936f11 (2022-11-29).
An immutable source reference is:
https://github.com/tensorflow/tfjs/blob/087a02a2848db8ba1950c6894fc76d8be3936f11/tfjs-backend-cpu/src/kernels/ResizeBilinearGrad.ts
Public GitHub issue search was queried for repo:tensorflow/tfjs ResizeBilinearGrad
and repo:tensorflow/tfjs resize gradient shape. These returned 7 and 2 results
respectively, including pull requests; none of their returned titles matched
this rectangular CPU gradient shape defect. This is a limited duplicate search,
not proof that no prior report exists. No issue has been submitted by this diagnostic.
Only installed 4.22.0 was runtime-tested. The public source view does not establish
a fresh runtime test of current upstream. Check existing issues before filing;
absence of a matching web-search result does not establish that no duplicate exists.
- Ngôn ngữ chính
- TypeScript
- Star
- 19.2k
- Fork
- 2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tensorflow/tfjs
-
conv3d, maxPool3d and avgPool3d with pad 'same' use the wrong window when the filter is smaller than the strideCó thể đã có người làm @nileshau-afk đã nhận 1 ngày trước. Đang mởcomp:core type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
tensorflow/tfjs#8753 · 1 người được giao ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 28/100
tensorflow/tfjs#8759 ·
-
tf.stridedSlice returns wrong values or throws when shrinkAxisMask is combined with a non-unit stride on another axisCó thể đã có người làm @nileshau-afk đã nhận 1 ngày trước. Đang mởcomp:backend-cpu comp:core type:bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
tensorflow/tfjs#8756 · 1 người được giao ·
-
Review argparse dependency bringing in sprintf-js CVE-2026-97058Có thể đã có người làm @Varun-S10 đã nhận 22 ngày trước. Đang mởtype:others type:support
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
tensorflow/tfjs#8749 · 1 người được giao ·
-
`@tensorflow/tfjs-node` installation issueCó thể làm lại được @nileshau-afk đã nhận 32 ngày trước và không có pull request nào đang mở. Đang mởcomp:node.js type:build/install
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
tensorflow/tfjs#8748 · 1 người được giao ·
Tất cả issue của tensorflow/tfjs
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
home-assistant/frontend#55841 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
lingdojo/kana-dojo#33905 · 1 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(semester-planning): the edit application dialog cannot save with an empty «Annet fra bedriften»Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
blocklist removal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
MetaMask/eth-phishing-detect#311215 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Explore filter: multi-select value list with allowNewOptions stops accepting values and drops earlier onesCó thể đã có người làm @isaac-jaynes-imperva đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/superset#46146 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày