pub struct Op { /* private fields */ }
Expand description
Op is the Rc wrapper of typed op trait
Implementations§
Source§impl Op
impl Op
pub fn new(op: Rc<RefCell<Box<dyn OpTrait>>>) -> Self
pub fn inner(&self) -> &Rc<RefCell<Box<dyn OpTrait>>>
pub fn ref_copy(&self) -> Self
pub fn get_name(&self) -> String
pub fn get_input_size(&self) -> usize
pub fn get_output_size(&self) -> usize
Sourcepub fn apply(&self, input: &[Tensor], output: &[Tensor])
pub fn apply(&self, input: &[Tensor], output: &[Tensor])
Read the input, do the calculation and write result to output. Called by compute_grapyh.
Sourcepub fn grad(
&self,
input: &[Tensor],
output_grad: &[Tensor],
input_grad: &[Tensor],
)
pub fn grad( &self, input: &[Tensor], output_grad: &[Tensor], input_grad: &[Tensor], )
Given input and output_grad, return input_grad (forward view) Called by compute_grapyh.
Sourcepub fn get_values(&self) -> Vec<Tensor>
pub fn get_values(&self) -> Vec<Tensor>
access weight/paramenters
Sourcepub fn set_values(&self, v: &[Tensor])
pub fn set_values(&self, v: &[Tensor])
set parameters
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Op
impl<'de> Deserialize<'de> for Op
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Op
impl !RefUnwindSafe for Op
impl !Send for Op
impl !Sync for Op
impl Unpin for Op
impl !UnwindSafe for Op
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