Skip to main content

transpose

Function transpose 

Source
pub fn transpose<Op: PrimitiveOp>(
    linear: &LinearFragment<Op>,
    ctx: &mut Op::ADContext,
) -> LinearFragment<Op>
where Op::InputKey: ADKey,
Expand description

Transpose a linear fragment, reversing linear flow.

Fan-out accumulation is emitted explicitly with [chainrules::PrimitiveOp::add]; no duplication primitive is assumed by the graph transform.

§Examples

let mut ctx = ();
let transposed = tidu::transpose(&linear_fragment, &mut ctx);
assert_eq!(transposed.tangent_outputs.len(), linear_fragment.tangent_inputs.len());