Skip to main content

Module batching

Module batching 

Source
Expand description

Helpers for batching rules (vmap), shared by the primitives and the vmap driver in ruxla-transforms.

The rules follow JAX’s batching rules, so that a function batched by ruxla compiles to the same program as one batched by JAX.

Functions§

batched_dim
Maps a dimension of one example to the dimension of the batched value whose batch dimension is bdim.
bdim_at_front
Returns x with its batch dimension first, broadcasting it if it is unbatched.
elementwise
The batching rule of elementwise primitives, whose operands have the same shape: operands batched at the same dimension are used as they are; otherwise every operand is moved (or broadcast) to have its batch dimension first.
insert_dim
Returns dims with size inserted at position at.
move_bdim
Returns x with its batch dimension at to, broadcasting it if it is unbatched.