ferrite

Struct Tensor

Source
pub struct Tensor { /* private fields */ }

Implementations§

Source§

impl Tensor

Source

pub fn new(tensor: TensorStorage, requires_grad: bool) -> Self

Source

pub fn tensor(&self) -> &TensorStorage

Source

pub fn tensor_mut(&mut self) -> &mut TensorStorage

Source

pub fn requires_grad(&self) -> &bool

Source

pub fn grad_fn(&self) -> Option<Rc<dyn GradientFunction>>

Source

pub fn set_grad_fn(&mut self, grad_fn: Option<Rc<dyn GradientFunction>>)

Source

pub fn grad(&self) -> Option<Rc<RefCell<TensorStorage>>>

Source

pub fn backward(&mut self)

Trait Implementations§

Source§

impl Add<&Tensor> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Tensor) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for Tensor

Source§

fn clone(&self) -> Tensor

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tensor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Tensor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Mul<&Tensor> for &Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Tensor) -> Self::Output

Performs the * operation. Read more
Source§

impl TensorCreation for Tensor

Source§

fn zeros(shape: Vec<usize>, requires_grad: Option<bool>) -> Self

Source§

fn ones(shape: Vec<usize>, requires_grad: Option<bool>) -> Self

Source§

fn from_ndarray<S, D, T>( data: &ArrayBase<S, D>, requires_grad: Option<bool>, ) -> Self
where S: Data<Elem = T>, T: AsPrimitive<f32>, D: Dimension,

Source§

impl TensorOps for Tensor

Source§

fn add_tensor(&self, other: &Self) -> Self

Source§

fn mul_tensor(&self, other: &Self) -> Self

Source§

fn sum(&self) -> Self

Source§

fn mean(&self) -> Self

Source§

fn product(&self) -> Self

Source§

fn sub_tensor(&self, other: &Self) -> Self

Source§

fn div_tensor(&self, other: &Self) -> Self

Source§

fn add_f32(&self, other: f32) -> Self

Source§

fn sub_f32(&self, other: f32) -> Self

Source§

fn mul_f32(&self, other: f32) -> Self

Source§

fn div_f32(&self, other: f32) -> Self

Source§

fn add_tensor_assign(&mut self, other: &Self)

Source§

fn sub_tensor_assign(&mut self, other: &Self)

Source§

fn mul_tensor_assign(&mut self, other: &Self)

Source§

fn div_tensor_assign(&mut self, other: &Self)

Source§

fn add_f32_assign(&mut self, other: f32)

Source§

fn sub_f32_assign(&mut self, other: f32)

Source§

fn mul_f32_assign(&mut self, other: f32)

Source§

fn div_f32_assign(&mut self, other: f32)

Source§

fn matmul(&self, other: &Self) -> Self

Source§

impl TensorShape for Tensor

Source§

fn reshape(&mut self, new_shape: Vec<usize>)

Source§

fn transpose(&mut self)

Source§

fn permute(&mut self, dims: &[usize])

Source§

fn flatten(&mut self)

Source§

fn squeeze(&mut self)

Source§

fn unsqueeze(&mut self, dim: usize)

Source§

fn broadcast(&self, new_shape: &[usize]) -> Self

Source§

fn compute_broadcast_shape(&self, target_shape: &[usize]) -> Vec<usize>

Source§

fn compute_broadcast_strides(&self, broadcast_shape: &[usize]) -> Vec<usize>

Source§

fn pad_shape(&self, target_rank: usize) -> Vec<usize>

Source§

fn broadcast_tensors(a: &Self, b: &Self) -> (Self, Self)

Auto Trait Implementations§

§

impl Freeze for Tensor

§

impl !RefUnwindSafe for Tensor

§

impl !Send for Tensor

§

impl !Sync for Tensor

§

impl Unpin for Tensor

§

impl !UnwindSafe for Tensor

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.