Skip to main content

Tensor

Struct Tensor 

Source
pub struct Tensor<Shape: TensorShape>(/* private fields */);

Implementations§

Source§

impl<Shape> Tensor<Shape>
where Shape: TensorShape,

Source

pub fn from_flat(data: [Float; Shape::SIZE]) -> Self

Source

pub fn from_elem(value: Float) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn rank(&self) -> usize

Source

pub fn as_slice(&self) -> &[Float]

Source

pub fn as_mut_slice(&mut self) -> &mut [Float]

Source

pub fn at(&self, index: [usize; Shape::RANK]) -> &Float

Source

pub fn set(&mut self, index: [usize; Shape::RANK], value: Float)

Source

pub fn fill(&mut self, value: Float)

Source

pub fn zeros() -> Self

Source

pub fn random() -> Self

Source

pub fn random_with_seed(seed: u64) -> Self

Source

pub fn random_with<R>(rng: &mut R) -> Self
where R: Rng + ?Sized,

Source

pub fn reshape<NewShape>(self) -> Tensor<NewShape>
where NewShape: TensorShape, (): ReshapePreservesElementCount<{ Shape::SIZE }, { NewShape::SIZE }>,

Source

pub fn as_ref(&self) -> TensorRef<'_, Shape>

Source

pub fn as_mut(&mut self) -> TensorMut<'_, Shape>

Source

pub fn map_inplace<F>(&mut self, f: F)
where F: FnMut(Float) -> Float,

Source

pub fn map<F>(&self, f: F) -> Self
where F: FnMut(Float) -> Float,

Source

pub fn zip_map<F>(&self, rhs: &Self, f: F) -> Self
where F: FnMut(Float, Float) -> Float,

Source

pub fn sum(&self) -> Float

Source

pub fn mean(&self) -> Float

Source

pub fn slice<T: Iterator>(_range: T)

👎Deprecated:

Tensor::slice is not implemented yet

Source§

impl<Shape> Tensor<Shape>
where Shape: NonScalarShape,

Source

pub fn get_ref(&self, index: usize) -> TensorRef<'_, Shape::Subshape>

Source

pub fn get_mut(&mut self, index: usize) -> TensorMut<'_, Shape::Subshape>

Source

pub fn get(&self, index: usize) -> Tensor<Shape::Subshape>

Source§

impl<const N: usize> Tensor<Dim<N, Nil>>

Source

pub fn dot(&self, rhs: &Self) -> Float

Source§

impl<const ROWS: usize, const COLS: usize> Tensor<Dim<ROWS, Dim<COLS, Nil>>>

Source

pub fn transpose(&self) -> Tensor<Dim<COLS, Dim<ROWS, Nil>>>

Source

pub fn matvec(&self, rhs: &Tensor<Dim<COLS, Nil>>) -> Tensor<Dim<ROWS, Nil>>

Source

pub fn matmul<const OUT_COLS: usize>( &self, rhs: &Tensor<Dim<COLS, Dim<OUT_COLS, Nil>>>, ) -> Tensor<Dim<ROWS, Dim<OUT_COLS, Nil>>>

Trait Implementations§

Source§

impl<Shape> Add<&Tensor<Shape>> for &Tensor<Shape>
where Shape: TensorShape,

Source§

type Output = Tensor<Shape>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<Shape> Add<&Tensor<Shape>> for Tensor<Shape>
where Shape: TensorShape,

Source§

type Output = Tensor<Shape>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<Shape> Add<f64> for Tensor<Shape>
where Shape: TensorShape,

Source§

type Output = Tensor<Shape>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<Shape> AddAssign<&Tensor<Shape>> for Tensor<Shape>
where Shape: TensorShape,

Source§

fn add_assign(&mut self, rhs: &Tensor<Shape>)

Performs the += operation. Read more
Source§

impl<Shape> AddAssign<f64> for Tensor<Shape>
where Shape: TensorShape,

Source§

fn add_assign(&mut self, rhs: Float)

Performs the += operation. Read more
Source§

impl<Shape> Clone for Tensor<Shape>
where Shape: TensorShape,

Source§

fn clone(&self) -> Self

Returns a duplicate 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<Shape> Debug for Tensor<Shape>
where Shape: TensorShape,

Source§

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

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

impl<Shape> Default for Tensor<Shape>
where Shape: TensorShape,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Shape> Div<f64> for Tensor<Shape>
where Shape: TensorShape,

Source§

type Output = Tensor<Shape>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Float) -> Self::Output

Performs the / operation. Read more
Source§

impl<Shape> DivAssign<f64> for Tensor<Shape>
where Shape: TensorShape,

Source§

fn div_assign(&mut self, rhs: Float)

Performs the /= operation. Read more
Source§

impl<const N: usize> From<[f64; N]> for Tensor<Dim<N, Nil>>

Source§

fn from(value: [Float; N]) -> Self

Converts to this type from the input type.
Source§

impl<Shape> Mul<&Tensor<Shape>> for &Tensor<Shape>
where Shape: TensorShape,

Source§

type Output = Tensor<Shape>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<Shape> Mul<&Tensor<Shape>> for Tensor<Shape>
where Shape: TensorShape,

Source§

type Output = Tensor<Shape>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<Shape> Mul<f64> for Tensor<Shape>
where Shape: TensorShape,

Source§

type Output = Tensor<Shape>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<Shape> MulAssign<&Tensor<Shape>> for Tensor<Shape>
where Shape: TensorShape,

Source§

fn mul_assign(&mut self, rhs: &Tensor<Shape>)

Performs the *= operation. Read more
Source§

impl<Shape> MulAssign<f64> for Tensor<Shape>
where Shape: TensorShape,

Source§

fn mul_assign(&mut self, rhs: Float)

Performs the *= operation. Read more
Source§

impl<Shape> Sub<&Tensor<Shape>> for &Tensor<Shape>
where Shape: TensorShape,

Source§

type Output = Tensor<Shape>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Tensor<Shape>) -> Self::Output

Performs the - operation. Read more
Source§

impl<Shape> Sub<&Tensor<Shape>> for Tensor<Shape>
where Shape: TensorShape,

Source§

type Output = Tensor<Shape>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Tensor<Shape>) -> Self::Output

Performs the - operation. Read more
Source§

impl<Shape> Sub<f64> for Tensor<Shape>
where Shape: TensorShape,

Source§

type Output = Tensor<Shape>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Float) -> Self::Output

Performs the - operation. Read more
Source§

impl<Shape> SubAssign<&Tensor<Shape>> for Tensor<Shape>
where Shape: TensorShape,

Source§

fn sub_assign(&mut self, rhs: &Tensor<Shape>)

Performs the -= operation. Read more
Source§

impl<Shape> SubAssign<f64> for Tensor<Shape>
where Shape: TensorShape,

Source§

fn sub_assign(&mut self, rhs: Float)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<Shape> Freeze for Tensor<Shape>

§

impl<Shape> RefUnwindSafe for Tensor<Shape>
where Shape: RefUnwindSafe,

§

impl<Shape> Send for Tensor<Shape>
where Shape: Send,

§

impl<Shape> Sync for Tensor<Shape>
where Shape: Sync,

§

impl<Shape> Unpin for Tensor<Shape>
where Shape: Unpin,

§

impl<Shape> UnsafeUnpin for Tensor<Shape>

§

impl<Shape> UnwindSafe for Tensor<Shape>
where Shape: UnwindSafe,

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V