Skip to content

Write output dims before the zero-batch early return - #11527

Open
anagnorisis2peripeteia wants to merge 1 commit into
google:masterfrom
anagnorisis2peripeteia:fix-zero-batch-output-dims-conv-transpose
Open

anagnorisis2peripeteia wants to merge 1 commit into
google:masterfrom
anagnorisis2peripeteia:fix-zero-batch-output-dims-conv-transpose

Conversation

@anagnorisis2peripeteia

Copy link
Copy Markdown
Contributor

Extends #11526 (pooling) to convolution, deconvolution, depth_to_space (both layouts), and space_to_depth: same stale out-param defect on the batch==0 path, proven with stale SIZE_MAX before and correct dims after in all five tests. Also replaces depth_to_space's raw dimension multiplies with guarded versions. 2408 tests pass, UBSan silent.

anagnorisis2peripeteia added a commit to anagnorisis2peripeteia/XNNPACK that referenced this pull request Oct 7, 2026
reshape_deconvolution2d_nhwc returns at batch_size == 0 before
reshape_igemm_path, which is the only writer of *workspace_size. The
pqs8_qs8_qc8w variant is the only deconvolution type that passes a
non-NULL workspace_size (src/subgraph/deconvolution-2d.c:491), so its
caller reads an unwritten value; src/subgraph/deconvolution-2d.c:519
then compares that against old_workspace_size to decide on
reallocation.

Same defect and fix as google#11530, on the deconvolution side. Distinct from
google#11527: that PR moves the early return past the output-dim writes, but
still before the workspace write, so it does not cover this.
convolution, deconvolution, depth_to_space (nhwc + nchw2nhwc), and
space_to_depth reshape returned success on batch_size == 0 without
writing the output-dimension out-params, leaving stale values the
subgraph writes into output shapes. Move each early return below the
out-param writes; setup short-circuits on skip state so the extra
computation is harmless. The depth_to_space raw input_height *
block_size writes are replaced with guarded safe_mul versions. All
five regression tests show stale SIZE_MAX without the fix and correct
dims with it.
@anagnorisis2peripeteia
anagnorisis2peripeteia force-pushed the fix-zero-batch-output-dims-conv-transpose branch from 7bd913c to 9f9745f Compare October 7, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant