Skip to content

Remove "atom specific" functions from matrix classes - PR 3 - #122

Merged
dance858 merged 1 commit into
mainfrom
row-gather-broadcast
Sep 12, 2026
Merged

dance858 merged 1 commit into
mainfrom
row-gather-broadcast

Conversation

@dance858

@dance858 dance858 commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Removes the broadcast variants from the matrix class. Finishes the clean up for a better abstraction.

Claude below:

Summary

Third PR of lesson 3 (M2b), rebased onto main after #121 merged.

  • The three broadcast variants are row gathers with fixed maps over the column-major output index r = i + j*d1: ROW copies child row j, COL copies child row i, SCALAR copies row 0. jacobian_init_impl builds the map, calls row_gather_alloc, frees it; eval_jacobian_impl calls row_gather_fill_values.
  • Deleted: broadcast_alloc / broadcast_fill_values slots, sparse_broadcast_*, broadcast_pd_* (+ decls), the stacked_pd ctx/wrapper/vtable functions, their wiring, and tile_int (its only caller was the sparse broadcast kernel).
  • broadcast_type moves from matrix.h to subexpr.h, its only remaining user.
  • No behaviour change: the gathers reproduce the structures the old kernels built.

Tests

  • New test_broadcast_row_jacobian_pd_preserved and test_broadcast_col_jacobian_pd_preserved: a pd child Jacobian stays pd through ROW and COL broadcasts, values checked row by row.
  • Removed the four unit tests of the deleted slot (test_permuted_dense_broadcast_{scalar,row,col}, test_spd_vtable_broadcast_row); the M1 gather tests cover the kernels.
  • Existing broadcast forward / Jacobian / Hessian / problem-level tests unchanged.

@dance858
dance858 changed the base branch from row-gather-promote to main September 12, 2026 21:24
…(lesson 3, M2b)

The three broadcast variants are row gathers with fixed maps over the
column-major output index r = i + j*d1: ROW copies child row j, COL copies
child row i, SCALAR copies row 0. The atom builds that map in jacobian_init;
the broadcast_alloc / broadcast_fill_values slots, their sparse,
permuted_dense and stacked_pd kernels, and the now-unused tile_int helper
are removed. broadcast_type moves from matrix.h to subexpr.h, its only
remaining user. Two new atom-level tests prove a pd child stays pd through
ROW and COL broadcasts.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Azb8o1AgiFRU4t9aAY7oDr
@dance858
dance858 force-pushed the row-gather-broadcast branch from bdef1e5 to adf46d1 Compare September 12, 2026 21:25
@dance858 dance858 changed the title Migrate broadcast onto row_gather; delete the broadcast vtable slots (lesson 3, M2b) Remove "atom specific" functions from matrix classes - PR 3 Sep 12, 2026
@dance858
dance858 merged commit 7bfb642 into main Sep 12, 2026
12 checks passed
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