Runs body a fixed number of times, threading a carry through the steps
and stacking each step's outputs along a new leading axis. Step t
receives the carry and, for every array in xs, its slice at position t
along axis 1 with that axis dropped.
Arguments
- init
(
list())
Initial carry: a (possibly nested) list of arrays. Every leaf keeps its shape and data type across steps.- xs
(
list())
Per-step inputs: a (possibly nested) list of arrays sliced along axis 1, all of sizelengthalong it. An empty list runs a counted loop.- body
(
function)
Step functionfunction(carry, x)returninglist(carry = , out = ), wherecarryhas the structure ofinitandoutis a (possibly nested) list of arrays orNULL.xisNULLwhenxsis empty.- length
(
integer(1))
Static trip count; the size of axis 1 of every array inxs.0runs no step and returnsinitwith zero-length stacked outputs.- reverse
(
logical(1))
IfTRUE, steps run fromlengthdown to1; each step still readsxsat its own position and writes its output there.
Value
list(carry = , out = ): the final carry and the stacked
outputs, each leaf of out gaining a leading axis of size length.
StableHLO
Lowers to hlo_while() over a counter, the carry, the output buffers and
xs, with hlo_dynamic_slice() reading each step's inputs and
hlo_dynamic_update_slice() writing its outputs.