Skip to main content

ExtensionPrimalVjpRule

Trait ExtensionPrimalVjpRule 

Source
pub trait ExtensionPrimalVjpRule:
    Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn family_id(&self) -> &'static str;
    fn primal_vjp(
        &self,
        op: &(dyn ExtensionOp + 'static),
        builder: &mut dyn PrimitiveRuleBuilder,
        cotangent_out: &[Option<usize>],
        inputs: &[ValueRef<StdTensorOp>],
        ctx: &mut ShapeGuardContext,
    ) -> Result<Vec<Option<usize>>, ADRuleError>;
}
Expand description

Optional direct primal VJP rule provider for an extension family.

This is an opt-in performance or compatibility escape hatch. The default reverse-mode path remains linearize followed by linear_transpose.

Required Methods§

Source

fn family_id(&self) -> &'static str

The extension family this rule handles.

Source

fn primal_vjp( &self, op: &(dyn ExtensionOp + 'static), builder: &mut dyn PrimitiveRuleBuilder, cotangent_out: &[Option<usize>], inputs: &[ValueRef<StdTensorOp>], ctx: &mut ShapeGuardContext, ) -> Result<Vec<Option<usize>>, ADRuleError>

Emit a direct VJP from the primal op.

Implementors§