dim-reduce: implement the 7 dimension-reduction kernels + kernel backlog - #42
Open
plotfi wants to merge 1 commit into
Open
dim-reduce: implement the 7 dimension-reduction kernels + kernel backlog#42plotfi wants to merge 1 commit into
plotfi wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.cuhGeneric reduce-along-axis: a tensor factors as
[outer, L, inner]arounddim(L = shape[dim]), sooutput[o,i] = reduce_l input[o*L*inner + l*inner + i], one thread per output element.shapeis a device pointer, copied to host to compute the three extents. Handles arbitrarydim/ndim, not just the test's 2-D case.Implemented (one-liners on the framework)
sum-dimmean-dimmax-dimmin-dimproduct-dimsize_tshape)argmaxargminintoutput/shape, first-index ties)All 7 pass their correctness tests.
KERNEL_BACKLOG.mdThe 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