Expand description
Transformations of the IR: vmap, jvp, partial evaluation,
transposition, vjp, and grad.
vmap batches a function with each primitive’s batching rule. jvp
differentiates in forward mode with each primitive’s JVP rule; vjp
linearizes (jvp and partial_eval) and transposes the linear
part, as JAX does; value_and_grad builds a gradient function.
Structs§
- Partial
Eval - The two parts of a function split by
partial_eval. - Vjp
- The two halves of reverse-mode differentiation, from
vjp.
Functions§
- jvp
- Differentiates
fin forward mode. - partial_
eval - Splits
finto the computation of what depends only on the inputs markedknown, and the rest, as JAX’s partial evaluation does. Outputs markedinstantiateare made unknown (passed through as residuals if they are known). Equations whose inputs are all known are known. - transpose
- Transposes
f, which must be linear in the inputs markedlinear. - value_
and_ grad - A function that returns the outputs of
fand the gradient of its first output (a float scalar, the loss) with respect to the inputs markedwrt:value_and_grad. The other outputs are auxiliary values, as with JAX’shas_aux, and are not differentiated. - vjp
- Linearizes
fand transposes it: reverse-mode differentiation with respect to the inputs markedwrt(which must be floats). - vmap
- Batches
fover a batch ofaxis_sizeexamples. - vmap_
with_ out_ axes vmapwith the batch dimension of each output:Some(d)puts it at dimensiond(broadcasting outputs that do not depend on the batched inputs), andNonerequires the output to be the same for every example.