Skip to main content

BackwardExecutor

Trait BackwardExecutor 

Source
pub trait BackwardExecutor<Op: Primitive>
where Op::InputKey: ADKey,
{ // Required methods fn execute_forward( &mut self, graph: PrimitiveGraph<'_, Op>, initial_data: &HashMap<ValueKey<Op>, Arc<Op::Operand>>, ) -> HashMap<ValueKey<Op>, Arc<Op::Operand>>; fn run_transposed_linear( &mut self, linear: &LinearizedGraph<Op>, cotangent_out: &[Option<Arc<Op::Operand>>], external_data: &HashMap<ValueKey<Op>, Arc<Op::Operand>>, ctx: &mut Op::ADContext, ) -> ADRuleResult<Vec<Option<Arc<Op::Operand>>>>; fn add_operands( &mut self, a: &Arc<Op::Operand>, b: &Arc<Op::Operand>, ) -> Arc<Op::Operand>; // Provided method fn linearize_recorded_graph( &mut self, graph: &RecordedGraph<Op>, output_slots: &[usize], ctx: &mut Op::ADContext, ) -> ADRuleResult<Arc<LinearizedGraph<Op>>> { ... } }
Expand description

Downstream execution hooks for eager backward.

Required Methods§

Source

fn execute_forward( &mut self, graph: PrimitiveGraph<'_, Op>, initial_data: &HashMap<ValueKey<Op>, Arc<Op::Operand>>, ) -> HashMap<ValueKey<Op>, Arc<Op::Operand>>

Replay a primitive graph and return any concrete values needed by transpose execution.

Source

fn run_transposed_linear( &mut self, linear: &LinearizedGraph<Op>, cotangent_out: &[Option<Arc<Op::Operand>>], external_data: &HashMap<ValueKey<Op>, Arc<Op::Operand>>, ctx: &mut Op::ADContext, ) -> ADRuleResult<Vec<Option<Arc<Op::Operand>>>>

Run a transposed linear graph with concrete cotangent seeds.

Source

fn add_operands( &mut self, a: &Arc<Op::Operand>, b: &Arc<Op::Operand>, ) -> Arc<Op::Operand>

Add two concrete operands for cotangent accumulation.

Provided Methods§

Source

fn linearize_recorded_graph( &mut self, graph: &RecordedGraph<Op>, output_slots: &[usize], ctx: &mut Op::ADContext, ) -> ADRuleResult<Arc<LinearizedGraph<Op>>>

Linearize one recorded eager graph node for the active output slots.

The default implementation calls RecordedGraph::linearize. Runtime owners may override this to memoize per-node transform results without taking trace traversal ownership away from tidu.

Implementors§