pub struct ScaleOperation;Expand description
A simple element-wise scaling operation
Trait Implementations§
Source§impl<T: TensorElement + Copy + Mul<Output = T> + FromPrimitive> CustomOperation<T> for ScaleOperation
impl<T: TensorElement + Copy + Mul<Output = T> + FromPrimitive> CustomOperation<T> for ScaleOperation
Source§fn description(&self) -> &str
fn description(&self) -> &str
Get a description of what this operation does
Source§fn forward(
&self,
inputs: &[Tensor<T>],
params: &OperationParams,
) -> Result<Vec<Tensor<T>>>
fn forward( &self, inputs: &[Tensor<T>], params: &OperationParams, ) -> Result<Vec<Tensor<T>>>
Execute the forward pass of the operation Read more
Source§fn backward(
&self,
grad_outputs: &[Tensor<T>],
_inputs: &[Tensor<T>],
_outputs: &[Tensor<T>],
params: &OperationParams,
) -> Result<Vec<Option<Tensor<T>>>>
fn backward( &self, grad_outputs: &[Tensor<T>], _inputs: &[Tensor<T>], _outputs: &[Tensor<T>], params: &OperationParams, ) -> Result<Vec<Option<Tensor<T>>>>
Execute the backward pass of the operation (optional for non-differentiable ops) Read more
Source§fn output_shapes(
&self,
input_shapes: &[Vec<usize>],
_params: &OperationParams,
) -> Result<Vec<Vec<usize>>>
fn output_shapes( &self, input_shapes: &[Vec<usize>], _params: &OperationParams, ) -> Result<Vec<Vec<usize>>>
Get the expected output shapes given input shapes Read more
Source§fn num_inputs(&self) -> usize
fn num_inputs(&self) -> usize
Get the number of expected inputs
Source§fn num_outputs(&self) -> usize
fn num_outputs(&self) -> usize
Get the number of expected outputs
Source§fn validate_inputs(
&self,
inputs: &[Tensor<T>],
_params: &OperationParams,
) -> Result<()>
fn validate_inputs( &self, inputs: &[Tensor<T>], _params: &OperationParams, ) -> Result<()>
Validate that the inputs are compatible with this operation Read more
Source§fn supports_autograd(&self) -> bool
fn supports_autograd(&self) -> bool
Check if this operation supports automatic differentiation
Auto Trait Implementations§
impl Freeze for ScaleOperation
impl RefUnwindSafe for ScaleOperation
impl Send for ScaleOperation
impl Sync for ScaleOperation
impl Unpin for ScaleOperation
impl UnsafeUnpin for ScaleOperation
impl UnwindSafe for ScaleOperation
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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