Struct TensorStack

Source
pub struct TensorStack<T, S, const D: usize> { /* private fields */ }
Expand description

Combines two or more tensors with the same shape along a new dimension to create a Tensor with one additional dimension which stacks the sources together along that dimension.

Note: due to limitations in Rust’s const generics support, TensorStack only implements TensorRef for D from 1 to 6 (from sources of 0 to 5 dimensions respectively), and only supports tuple combinations for 2 to 4. If you need to stack more than four tensors together, you can stack any number with the [S; N] implementation, though note this requires that all the tensors are the same type so you may need to box and erase the types to Box<dyn TensorRef<T, D>>.

use easy_ml::tensors::Tensor;
use easy_ml::tensors::views::{TensorView, TensorStack, TensorRef};
let vector1 = Tensor::from([("data", 5)], vec![0, 1, 2, 3, 4]);
let vector2 = Tensor::from([("data", 5)], vec![2, 4, 8, 16, 32]);
// Because there are 4 variants of `TensorStack::from` you may need to use the turbofish
// to tell the Rust compiler which variant you're using, but the actual type of `S` can be
// left unspecified by using an underscore.
let matrix = TensorStack::<i32, [_; 2], 1>::from([&vector1, &vector2], (0, "sample"));
let equal_matrix = Tensor::from([("sample", 2), ("data", 5)], vec![
  0, 1, 2, 3, 4,
  2, 4, 8, 16, 32
]);
assert_eq!(equal_matrix, TensorView::from(matrix));

let also_matrix = TensorStack::<i32, (_, _), 1>::from((vector1, vector2), (0, "sample"));
assert_eq!(equal_matrix, TensorView::from(&also_matrix));

// To stack `equal_matrix` and `also_matrix` using the `[S; N]` implementation we have to first
// make them the same type, which we can do by boxing and erasing.
let matrix_erased: Box<dyn TensorRef<i32, 2>> = Box::new(also_matrix);
let equal_matrix_erased: Box<dyn TensorRef<i32, 2>> = Box::new(equal_matrix);
let tensor = TensorStack::<i32, [_; 2], 2>::from(
    [matrix_erased, equal_matrix_erased], (0, "experiment")
);
assert!(
    TensorView::from(tensor).eq(
        &Tensor::from([("experiment", 2), ("sample", 2), ("data", 5)], vec![
            0, 1, 2, 3, 4,
            2, 4, 8, 16, 32,

            0, 1, 2, 3, 4,
            2, 4, 8, 16, 32
        ])
    ),
);

Implementations§

Source§

impl<T, S, const D: usize, const N: usize> TensorStack<T, [S; N], D>
where S: TensorRef<T, D>,

Source

pub fn from(sources: [S; N], along: (usize, Dimension)) -> Self

Creates a TensorStack from an array of sources of the same type and a tuple of which dimension and name to stack the sources along in the range of 0 <= d <= D. The sources must all have an identical shape, and the dimension name to add must not be in the sources’ shape already.

§Panics

If N == 0, the shapes of the sources are not identical, the dimension for stacking is out of bounds, or the name is already in the sources’ shape.

While N == 1 arguments may be valid TensorExpansion is a more general way to add dimensions with no additional data.

Source

pub fn sources(self) -> [S; N]

Consumes the TensorStack, yielding the sources it was created from in the same order.

Source

pub fn sources_ref(&self) -> &[S; N]

Gives a reference to all the TensorStack’s sources it was created from in the same order

Source§

impl<T, S1, S2, const D: usize> TensorStack<T, (S1, S2), D>
where S1: TensorRef<T, D>, S2: TensorRef<T, D>,

Source

pub fn from(sources: (S1, S2), along: (usize, Dimension)) -> Self

Creates a TensorStack from two sources and a tuple of which dimension and name to stack the sources along in the range of 0 <= d <= D. The sources must all have an identical shape, and the dimension name to add must not be in the sources’ shape already.

§Panics

If the shapes of the sources are not identical, the dimension for stacking is out of bounds, or the name is already in the sources’ shape.

Source

pub fn sources(self) -> (S1, S2)

Consumes the TensorStack, yielding the sources it was created from in the same order.

Source

pub fn sources_ref(&self) -> &(S1, S2)

Gives a reference to all the TensorStack’s sources it was created from in the same order

Source§

impl<T, S1, S2, S3, const D: usize> TensorStack<T, (S1, S2, S3), D>
where S1: TensorRef<T, D>, S2: TensorRef<T, D>, S3: TensorRef<T, D>,

Source

pub fn from(sources: (S1, S2, S3), along: (usize, Dimension)) -> Self

Creates a TensorStack from three sources and a tuple of which dimension and name to stack the sources along in the range of 0 <= d <= D. The sources must all have an identical shape, and the dimension name to add must not be in the sources’ shape already.

§Panics

If the shapes of the sources are not identical, the dimension for stacking is out of bounds, or the name is already in the sources’ shape.

Source

pub fn sources(self) -> (S1, S2, S3)

Consumes the TensorStack, yielding the sources it was created from in the same order.

Source

pub fn sources_ref(&self) -> &(S1, S2, S3)

Gives a reference to all the TensorStack’s sources it was created from in the same order

Source§

impl<T, S1, S2, S3, S4, const D: usize> TensorStack<T, (S1, S2, S3, S4), D>
where S1: TensorRef<T, D>, S2: TensorRef<T, D>, S3: TensorRef<T, D>, S4: TensorRef<T, D>,

Source

pub fn from(sources: (S1, S2, S3, S4), along: (usize, Dimension)) -> Self

Creates a TensorStack from four sources and a tuple of which dimension and name to stack the sources along in the range of 0 <= d <= D. The sources must all have an identical shape, and the dimension name to add must not be in the sources’ shape already.

§Panics

If the shapes of the sources are not identical, the dimension for stacking is out of bounds, or the name is already in the sources’ shape.

Source

pub fn sources(self) -> (S1, S2, S3, S4)

Consumes the TensorStack, yielding the sources it was created from in the same order.

Source

pub fn sources_ref(&self) -> &(S1, S2, S3, S4)

Gives a reference to all the TensorStack’s sources it was created from in the same order

Trait Implementations§

Source§

impl<T: Clone, S: Clone, const D: usize> Clone for TensorStack<T, S, D>

Source§

fn clone(&self) -> TensorStack<T, S, 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<T: Debug, S: Debug, const D: usize> Debug for TensorStack<T, S, D>

Source§

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

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

impl<T, S, const N: usize> TensorMut<T, { $d + 1 }> for TensorStack<T, [S; N], 0>
where S: TensorMut<T, 0>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 1]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 1]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S, const N: usize> TensorMut<T, { $d + 1 }> for TensorStack<T, [S; N], 1>
where S: TensorMut<T, 1>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 2]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 2]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S, const N: usize> TensorMut<T, { $d + 1 }> for TensorStack<T, [S; N], 2>
where S: TensorMut<T, 2>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 3]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 3]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S, const N: usize> TensorMut<T, { $d + 1 }> for TensorStack<T, [S; N], 3>
where S: TensorMut<T, 3>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 4]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 4]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S, const N: usize> TensorMut<T, { $d + 1 }> for TensorStack<T, [S; N], 4>
where S: TensorMut<T, 4>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 5]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 5]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S, const N: usize> TensorMut<T, { $d + 1 }> for TensorStack<T, [S; N], 5>
where S: TensorMut<T, 5>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 6]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 6]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2), 0>
where S1: TensorMut<T, 0>, S2: TensorMut<T, 0>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 1]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 1]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2), 1>
where S1: TensorMut<T, 1>, S2: TensorMut<T, 1>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 2]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 2]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2), 2>
where S1: TensorMut<T, 2>, S2: TensorMut<T, 2>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 3]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 3]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2), 3>
where S1: TensorMut<T, 3>, S2: TensorMut<T, 3>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 4]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 4]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2), 4>
where S1: TensorMut<T, 4>, S2: TensorMut<T, 4>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 5]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 5]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2), 5>
where S1: TensorMut<T, 5>, S2: TensorMut<T, 5>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 6]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 6]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 0>
where S1: TensorMut<T, 0>, S2: TensorMut<T, 0>, S3: TensorMut<T, 0>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 1]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 1]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 1>
where S1: TensorMut<T, 1>, S2: TensorMut<T, 1>, S3: TensorMut<T, 1>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 2]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 2]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 2>
where S1: TensorMut<T, 2>, S2: TensorMut<T, 2>, S3: TensorMut<T, 2>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 3]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 3]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 3>
where S1: TensorMut<T, 3>, S2: TensorMut<T, 3>, S3: TensorMut<T, 3>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 4]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 4]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 4>
where S1: TensorMut<T, 4>, S2: TensorMut<T, 4>, S3: TensorMut<T, 4>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 5]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 5]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 5>
where S1: TensorMut<T, 5>, S2: TensorMut<T, 5>, S3: TensorMut<T, 5>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 6]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 6]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3, S4> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 0>
where S1: TensorMut<T, 0>, S2: TensorMut<T, 0>, S3: TensorMut<T, 0>, S4: TensorMut<T, 0>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 1]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 1]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3, S4> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 1>
where S1: TensorMut<T, 1>, S2: TensorMut<T, 1>, S3: TensorMut<T, 1>, S4: TensorMut<T, 1>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 2]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 2]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3, S4> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 2>
where S1: TensorMut<T, 2>, S2: TensorMut<T, 2>, S3: TensorMut<T, 2>, S4: TensorMut<T, 2>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 3]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 3]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3, S4> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 3>
where S1: TensorMut<T, 3>, S2: TensorMut<T, 3>, S3: TensorMut<T, 3>, S4: TensorMut<T, 3>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 4]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 4]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3, S4> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 4>
where S1: TensorMut<T, 4>, S2: TensorMut<T, 4>, S3: TensorMut<T, 4>, S4: TensorMut<T, 4>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 5]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 5]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S1, S2, S3, S4> TensorMut<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 5>
where S1: TensorMut<T, 5>, S2: TensorMut<T, 5>, S3: TensorMut<T, 5>, S4: TensorMut<T, 5>,

Source§

fn get_reference_mut(&mut self, indexes: [usize; 6]) -> Option<&mut T>

Gets a mutable reference to the value at the index, if the index is in range. Otherwise returns None.
Source§

unsafe fn get_reference_unchecked_mut(&mut self, indexes: [usize; 6]) -> &mut T

Gets a mutable reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference_mut. Read more
Source§

impl<T, S, const N: usize> TensorRef<T, { $d + 1 }> for TensorStack<T, [S; N], 0>
where S: TensorRef<T, 0>,

Source§

fn get_reference(&self, indexes: [usize; 1]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 1]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 1]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S, const N: usize> TensorRef<T, { $d + 1 }> for TensorStack<T, [S; N], 1>
where S: TensorRef<T, 1>,

Source§

fn get_reference(&self, indexes: [usize; 2]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 2]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 2]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S, const N: usize> TensorRef<T, { $d + 1 }> for TensorStack<T, [S; N], 2>
where S: TensorRef<T, 2>,

Source§

fn get_reference(&self, indexes: [usize; 3]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 3]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 3]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S, const N: usize> TensorRef<T, { $d + 1 }> for TensorStack<T, [S; N], 3>
where S: TensorRef<T, 3>,

Source§

fn get_reference(&self, indexes: [usize; 4]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 4]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 4]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S, const N: usize> TensorRef<T, { $d + 1 }> for TensorStack<T, [S; N], 4>
where S: TensorRef<T, 4>,

Source§

fn get_reference(&self, indexes: [usize; 5]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 5]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 5]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S, const N: usize> TensorRef<T, { $d + 1 }> for TensorStack<T, [S; N], 5>
where S: TensorRef<T, 5>,

Source§

fn get_reference(&self, indexes: [usize; 6]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 6]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 6]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2), 0>
where S1: TensorRef<T, 0>, S2: TensorRef<T, 0>,

Source§

fn get_reference(&self, indexes: [usize; 1]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 1]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 1]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2), 1>
where S1: TensorRef<T, 1>, S2: TensorRef<T, 1>,

Source§

fn get_reference(&self, indexes: [usize; 2]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 2]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 2]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2), 2>
where S1: TensorRef<T, 2>, S2: TensorRef<T, 2>,

Source§

fn get_reference(&self, indexes: [usize; 3]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 3]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 3]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2), 3>
where S1: TensorRef<T, 3>, S2: TensorRef<T, 3>,

Source§

fn get_reference(&self, indexes: [usize; 4]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 4]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 4]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2), 4>
where S1: TensorRef<T, 4>, S2: TensorRef<T, 4>,

Source§

fn get_reference(&self, indexes: [usize; 5]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 5]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 5]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2), 5>
where S1: TensorRef<T, 5>, S2: TensorRef<T, 5>,

Source§

fn get_reference(&self, indexes: [usize; 6]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 6]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 6]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 0>
where S1: TensorRef<T, 0>, S2: TensorRef<T, 0>, S3: TensorRef<T, 0>,

Source§

fn get_reference(&self, indexes: [usize; 1]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 1]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 1]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 1>
where S1: TensorRef<T, 1>, S2: TensorRef<T, 1>, S3: TensorRef<T, 1>,

Source§

fn get_reference(&self, indexes: [usize; 2]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 2]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 2]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 2>
where S1: TensorRef<T, 2>, S2: TensorRef<T, 2>, S3: TensorRef<T, 2>,

Source§

fn get_reference(&self, indexes: [usize; 3]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 3]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 3]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 3>
where S1: TensorRef<T, 3>, S2: TensorRef<T, 3>, S3: TensorRef<T, 3>,

Source§

fn get_reference(&self, indexes: [usize; 4]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 4]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 4]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 4>
where S1: TensorRef<T, 4>, S2: TensorRef<T, 4>, S3: TensorRef<T, 4>,

Source§

fn get_reference(&self, indexes: [usize; 5]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 5]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 5]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3), 5>
where S1: TensorRef<T, 5>, S2: TensorRef<T, 5>, S3: TensorRef<T, 5>,

Source§

fn get_reference(&self, indexes: [usize; 6]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 6]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 6]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3, S4> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 0>
where S1: TensorRef<T, 0>, S2: TensorRef<T, 0>, S3: TensorRef<T, 0>, S4: TensorRef<T, 0>,

Source§

fn get_reference(&self, indexes: [usize; 1]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 1]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 1]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3, S4> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 1>
where S1: TensorRef<T, 1>, S2: TensorRef<T, 1>, S3: TensorRef<T, 1>, S4: TensorRef<T, 1>,

Source§

fn get_reference(&self, indexes: [usize; 2]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 2]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 2]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3, S4> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 2>
where S1: TensorRef<T, 2>, S2: TensorRef<T, 2>, S3: TensorRef<T, 2>, S4: TensorRef<T, 2>,

Source§

fn get_reference(&self, indexes: [usize; 3]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 3]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 3]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3, S4> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 3>
where S1: TensorRef<T, 3>, S2: TensorRef<T, 3>, S3: TensorRef<T, 3>, S4: TensorRef<T, 3>,

Source§

fn get_reference(&self, indexes: [usize; 4]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 4]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 4]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3, S4> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 4>
where S1: TensorRef<T, 4>, S2: TensorRef<T, 4>, S3: TensorRef<T, 4>, S4: TensorRef<T, 4>,

Source§

fn get_reference(&self, indexes: [usize; 5]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 5]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 5]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more
Source§

impl<T, S1, S2, S3, S4> TensorRef<T, { $d + 1 }> for TensorStack<T, (S1, S2, S3, S4), 5>
where S1: TensorRef<T, 5>, S2: TensorRef<T, 5>, S3: TensorRef<T, 5>, S4: TensorRef<T, 5>,

Source§

fn get_reference(&self, indexes: [usize; 6]) -> Option<&T>

Gets a reference to the value at the index if the index is in range. Otherwise returns None.
Source§

fn view_shape(&self) -> [(Dimension, usize); 6]

The shape this tensor has. See dimensions for an overview. The product of the lengths in the pairs define how many elements are in the tensor (or the portion of it that is visible).
Source§

unsafe fn get_reference_unchecked(&self, indexes: [usize; 6]) -> &T

Gets a reference to the value at the index without doing any bounds checking. For a safe alternative see get_reference. Read more
Source§

fn data_layout(&self) -> DataLayout<{ _ }>

The way the data in this tensor is laid out in memory. In particular, Linear has several requirements on what is returned that must be upheld by implementations of this trait. Read more

Auto Trait Implementations§

§

impl<T, S, const D: usize> Freeze for TensorStack<T, S, D>
where S: Freeze,

§

impl<T, S, const D: usize> RefUnwindSafe for TensorStack<T, S, D>

§

impl<T, S, const D: usize> Send for TensorStack<T, S, D>
where S: Send, T: Send,

§

impl<T, S, const D: usize> Sync for TensorStack<T, S, D>
where S: Sync, T: Sync,

§

impl<T, S, const D: usize> Unpin for TensorStack<T, S, D>
where S: Unpin, T: Unpin,

§

impl<T, S, const D: usize> UnwindSafe for TensorStack<T, S, D>
where S: UnwindSafe, T: 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.