Skip to main content

NamedTensor

Struct NamedTensor 

Source
pub struct NamedTensor<B: Backend, D: NamedDims<B>> { /* private fields */ }
Expand description

A tensor with named dimensions.

Implementations§

Source§

impl<B: Backend, const D: usize, ND> NamedTensor<B, ND>
where ND: NamedDims<B, Tensor = Tensor<B, D>>,

Source

pub fn from_tensor(tensor: Tensor<B, D>) -> Self

Create a named tensor from a tensor.

Source

pub fn random<S: Into<Shape>>( shape: S, distribution: Distribution, device: &B::Device, ) -> Self

Create a random named tensor of the given shape where each element is sampled from the given distribution.

Source

pub fn shape(&self) -> Shape

Returns the shape of the current tensor.

Source

pub fn mul(self, rhs: Self) -> Self

Applies element wise multiplication operation.

y = x2 * x1

Source

pub fn reshape<const D2: usize, S, ND2>( self, shape: S, _: ND2, ) -> NamedTensor<B, ND2>
where S: Into<Shape>, ND2: NamedDims<B, Tensor = Tensor<B, D2>>,

Reshape the tensor to have the given shape.

§Panics

If the tensor can not be reshape to the given shape.

Source§

impl<B: Backend, const D: usize, ND> NamedTensor<B, ND>
where ND: NamedDims<B, Tensor = Tensor<B, D>>,

Source

pub fn matmul<NamedDimsRhs, NamedDimsOut>( self, rhs: NamedTensor<B, NamedDimsRhs>, ) -> NamedTensor<B, NamedDimsOut>
where NamedDimsRhs: NamedDims<B, Tensor = Tensor<B, D>>, NamedDimsOut: NamedDims<B, Tensor = Tensor<B, D>>, Self: Matmul<NamedTensor<B, NamedDimsRhs>, NamedTensor<B, NamedDimsOut>>,

Applies the matrix multiplication operation.

C = AB

§Panics

If the two tensors dont’ have a compatible shape.

Source§

impl<B: Backend, const D: usize, ND> NamedTensor<B, ND>
where ND: NamedDims<B, Tensor = Tensor<B, D>>,

Source

pub fn swap_dims<ND2, const D1: usize, const D2: usize>( self, ) -> NamedTensor<B, ND2>
where ND2: NamedDims<B, Tensor = Tensor<B, D>>, Self: SwapDims<NamedTensor<B, ND2>, D1, D2>,

Swap two dimensions.

Trait Implementations§

Source§

impl<B: Clone + Backend, D: Clone + NamedDims<B>> Clone for NamedTensor<B, D>
where D::Tensor: Clone,

Source§

fn clone(&self) -> NamedTensor<B, D>

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<B: Debug + Backend, D: Debug + NamedDims<B>> Debug for NamedTensor<B, D>
where D::Tensor: Debug,

Source§

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

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

impl<B: Backend, const D: usize, ND> Display for NamedTensor<B, ND>
where ND: NamedDims<B, Tensor = Tensor<B, D>> + NamedDims<B>,

Source§

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

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

impl<B: Backend, ND: NamedDims<B, Tensor = Tensor<B, D>>, const D: usize> From<NamedTensor<B, ND>> for Tensor<B, D>

Source§

fn from(nt: NamedTensor<B, ND>) -> Self

Converts to this type from the input type.
Source§

impl<B: Backend, ND: NamedDims<B, Tensor = Tensor<B, D>>, const D: usize> From<Tensor<B, D>> for NamedTensor<B, ND>

Source§

fn from(tensor: Tensor<B, D>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<B, D> Freeze for NamedTensor<B, D>
where <D as NamedDims<B>>::Tensor: Freeze,

§

impl<B, D> RefUnwindSafe for NamedTensor<B, D>
where <D as NamedDims<B>>::Tensor: RefUnwindSafe,

§

impl<B, D> Send for NamedTensor<B, D>
where <D as NamedDims<B>>::Tensor: Send,

§

impl<B, D> Sync for NamedTensor<B, D>
where <D as NamedDims<B>>::Tensor: Sync,

§

impl<B, D> Unpin for NamedTensor<B, D>
where <D as NamedDims<B>>::Tensor: Unpin,

§

impl<B, D> UnsafeUnpin for NamedTensor<B, D>
where <D as NamedDims<B>>::Tensor: UnsafeUnpin,

§

impl<B, D> UnwindSafe for NamedTensor<B, D>
where <D as NamedDims<B>>::Tensor: 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> 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.
Source§

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

Source§

fn vzip(self) -> V