Skip to content

dim-reduce: implement the 7 dimension-reduction kernels + kernel backlog - #42

Open
plotfi wants to merge 1 commit into
mainfrom
dim-reductions
Open

dim-reduce: implement the 7 dimension-reduction kernels + kernel backlog#42
plotfi wants to merge 1 commit into
mainfrom
dim-reductions

Conversation

@plotfi

@plotfi plotfi commented Aug 12, 2026

Copy link
Copy Markdown
Owner

What

Knocks out the EASY "Reduction" cluster — all 7 dimension-reduction kernels — on one shared framework, and adds a ranked backlog of the rest.

kernel-implementation/dim-reduce.cuh

Generic reduce-along-axis: a tensor factors as [outer, L, inner] around dim (L = shape[dim]), so output[o,i] = reduce_l input[o*L*inner + l*inner + i], one thread per output element. shape is a device pointer, copied to host to compute the three extents. Handles arbitrary dim/ndim, not just the test's 2-D case.

Implemented (one-liners on the framework)

Kernel Op
sum-dim mean-dim max-dim min-dim product-dim value reductions (float, size_t shape)
argmax argmin index reductions (int output/shape, first-index ties)

All 7 pass their correctness tests.

KERNEL_BACKLOG.md

The remaining ~49 stubs, ranked easiest→hardest from Problems.mhtml (EASY/MEDIUM/HARD) and clustered by similarity to existing frameworks (block-reduce/loss, reduction, gemm-epilogue/prologue, pooling, …), with a recommended max-reuse implementation order.

Verified

sum-dim … argmin: 7/7 tests pass.

🤖 Generated with Claude Code

…ramework

Adds kernel-implementation/dim-reduce.cuh: a generic reduce-along-axis kernel
(a tensor factors as [outer, L, inner] around dim; one thread per output element)
covering value reductions (sum/mean/max/min/product) and index reductions
(argmax/argmin). `shape` is a device pointer, copied to host to compute extents.

Implements all 7 as one-liners on top of it:
  sum-dim mean-dim max-dim min-dim product-dim  (float, size_t shape)
  argmax argmin                                 (int output, int shape, first-index ties)

All 7 pass their correctness tests (were the EASY 'Reduction' cluster). Also adds
KERNEL_BACKLOG.md: the remaining ~49 stubs ranked easiest->hardest (from
Problems.mhtml) and clustered by similarity to existing frameworks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012o3X6Kr1cr8yS6CaosQTa8
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