pub struct ScaledAddFunction { /* private fields */ }Expand description
Example custom function with context: Scaled addition
Implementations§
Trait Implementations§
Source§impl CustomAutogradFunctionWithContext for ScaledAddFunction
impl CustomAutogradFunctionWithContext for ScaledAddFunction
Source§fn forward(
&self,
ctx: &mut AutogradContext,
inputs: &[Tensor],
) -> TorshResult<Vec<Tensor>>
fn forward( &self, ctx: &mut AutogradContext, inputs: &[Tensor], ) -> TorshResult<Vec<Tensor>>
Forward pass with context
Source§fn backward(
&self,
ctx: &AutogradContext,
grad_outputs: &[Tensor],
) -> TorshResult<Vec<Option<Tensor>>>
fn backward( &self, ctx: &AutogradContext, grad_outputs: &[Tensor], ) -> TorshResult<Vec<Option<Tensor>>>
Backward pass with context
Source§fn num_inputs(&self) -> usize
fn num_inputs(&self) -> usize
Number of inputs expected by this function
Source§fn num_outputs(&self) -> usize
fn num_outputs(&self) -> usize
Number of outputs produced by this function
Auto Trait Implementations§
impl Freeze for ScaledAddFunction
impl RefUnwindSafe for ScaledAddFunction
impl Send for ScaledAddFunction
impl Sync for ScaledAddFunction
impl Unpin for ScaledAddFunction
impl UnsafeUnpin for ScaledAddFunction
impl UnwindSafe for ScaledAddFunction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more