Skip to content

Adds reduce_sum and reduce_max operations #300

Open
zoecarver wants to merge 7 commits intozoecarver/matmul-opfrom
zoecarver/reduce-ops
Open

Adds reduce_sum and reduce_max operations #300
zoecarver wants to merge 7 commits intozoecarver/matmul-opfrom
zoecarver/reduce-ops

Conversation

@zoecarver
Copy link
Contributor

Adds reduce_sum and reduce_max operations following the same CB-input pattern as bcast and matmul.

  • CB-input pattern: Reduce reads input tiles directly from CB, applies reduction, and writes to DST. Uses TTL_CBInputTileOpTrait for proper DST assignment handling
  • Reduction dimensions: Supports row reduction (collapse rows), column reduction (collapse columns), and scalar reduction (collapse to single value). The dimension is encoded as an enum attribute and determines which TTKernel pool operation is emitted. Frontend API matches bcast dims.
  • Multi-tile accumulation: When reducing across multiple input tiles, the lowering generates a loop that accumulates partial reductions. The scaler operand provides the reduction identity (0 for sum, -inf for max)
  • Two-stage lowering: ConvertTTLToCompute builds the reduction loop structure with proper scaler handling. ConvertTTLTileOpsToTTKernel emits the appropriate reduce intrinsic based on reduction type and dimension

Self-contained and follows bcast's established lowering path and reuses the same CB lookup utilities. Risk is limited to reduce ops (adds new lowering, does not modify existing lowering patterns).

@zoecarver zoecarver requested a review from a team as a code owner February 2, 2026 16:17
@zoecarver zoecarver changed the title Zoecarver/reduce ops Adds reduce_sum and reduce_max operations Feb 2, 2026
@zoecarver zoecarver force-pushed the zoecarver/matmul-op branch from fc646f5 to 2d9f3ed Compare February 2, 2026 16:49
@zoecarver zoecarver force-pushed the zoecarver/reduce-ops branch from bc85e71 to e74c621 Compare February 2, 2026 16:59
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