Skip to content

Frame generation: net1 max-pool kernel for HIP and D3D12, bit for bit against the CPU reference - #187

Merged
phantoslayer21 merged 3 commits into
mainfrom
fg/kernels-pool
Nov 14, 2026
Merged

phantoslayer21 merged 3 commits into
mainfrom
fg/kernels-pool

Conversation

@phantoslayer21

@phantoslayer21 phantoslayer21 commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Adds the second frame-generation GPU kernel family: net1's max-pool, for HIP and D3D12, byte-identical with each other and bit for bit against the CPU reference net1.maxpool2 (lane h). It builds on #183 (the conv kernel, the shared header and the check, now merged).

Kernel: fg_maxpool2_f16(x, y, C, H, W) in clean/fg/kernels/fg_net1.hip (code object fg_net1.co), with its D3D12 port clean/dx12/kernels/fg_pool.hlsl.

  • 2×2 window, stride 2, floor sizes (an odd last row or column is dropped).
  • Taps (0,0), (0,1), (1,0), (1,1) go through the delivered step m ← (x > m)·x + (x ≤ m)·m with IEEE products and sums: 0·inf is NaN, and a sum of zeros is −0 only when both are −0.
  • That step is fg_pool_step16, integer bit logic in the shared clean/fg/kernels/fg_exact16.h, so both back ends run the same code. NaN is written as 0x7E00.
  • Like every fg_ kernel it is built only when --only names it, so Model M's and Model L's kernel sets and DXILs are unchanged.

Check (clean/fg/runner/fg_d3d12_check.py)

  • New pool cases: random maps of six sizes (odd sizes included, up to 128 channels), and every window of four taps over ten special values, 10,000 windows: 1, −2, ±inf, NaN, ±0, ±65504, and the smallest subnormal.
  • Negative controls are now per kernel: every kernel's first case with four or more workgroups runs again on D3D12 with half of them, and each must be caught.

Refs #96

Tested

  • GPU check on the RX 9070 XT inside one GPU slot (gpu_slot.py --cap-s 170), three seeds, with the conv kernel in the same run: 285 cases (21 pool, 264 conv) and 1,873,263 output values.
    • HIP and D3D12 raw bytes are identical, and every slack byte kept its back end's sentinel (0xA5 / 0x5A).
    • HIP equals the CPU reference bit for bit, including 24,125 NaN and 5,546 inf outputs. The pool's special windows include results of −0.
    • Both negative controls were caught (pool 9,760 differing bytes, conv 1,214).
  • test_kernel_sets, the clean/fg unit tests, the line-ending check and the public gates pass, with no hits in the changed files.

Not tested

  • Speed (a correctness kernel); no timing was taken.
  • The upscale kernel follows in its own PR.

… against the CPU reference

fg_maxpool2_f16 (fg_net1.co) and its D3D12 port clean/dx12/kernels/fg_pool.hlsl:
2x2, stride 2, floor sizes, the delivered step m <- (x > m) x + (x <= m) m with
IEEE products and sums, as shared integer code (fg_pool_step16 in
clean/fg/kernels/fg_exact16.h). Built only with --only, as every fg_ kernel.

fg_d3d12_check.py: pool cases (random maps of several sizes, every window of
four taps over ten special values) and a caught half-grid negative control per
kernel.

Refs #96

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 merged commit 162a741 into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the fg/kernels-pool branch November 14, 2026 19:12
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