Skip to content
class

BroadcastPlan

BroadcastPlan

How a broadcast from src_shape to dst_shape lays out in runs.

The output is outer blocks, one after another. Block o reads the inner contiguous source elements that start at the offset its outer coordinate selects, and writes each of them rep times in a row — so a scalar is one block of one element repeated everywhere, a row vector is one contiguous copy per row, and a column is one fill per row. Walking runs instead of elements is what lets a copy or a fill do the work: the per-element coordinate walk this replaced cost 2.3 ns an element, fifty times a same-shape multiply, and every bias add and scalar product paid it.