[][src]Trait auto_diff::tensor::index_slicing::IndexSlicing

pub trait IndexSlicing {
    type TensorType;
    fn cat(&self, tensors: &[&Self::TensorType], dim: usize) -> Self::TensorType;
fn chunk(&self, chunks: usize, dim: usize) -> Vec<Self::TensorType>;
fn gather(&self, dim: usize, index: &Self::TensorType) -> Self::TensorType;
fn index_select(
        &self,
        dim: usize,
        index: &Self::TensorType
    ) -> Self::TensorType;
fn reshape(&self, new_shape: &[usize]) -> Self::TensorType;
fn split(&self, sections: &[usize], dim: usize) -> Vec<Self::TensorType>;
fn squeeze(&self, dim: Option<usize>) -> Self::TensorType;
fn stack(tensors: &[&Self], dim: usize) -> Self::TensorType;
fn take(&self, index: &[usize]) -> Self::TensorType;
fn permute(&self, dims: &[usize]) -> Self::TensorType;
fn unsqueeze(&self, dim: usize) -> Self::TensorType;
fn conditional_select(
        &self,
        x: &Self::TensorType,
        y: &Self::TensorType
    ) -> Self::TensorType;
fn repeat(&self, sizes: &[usize]) -> Self::TensorType; }

Associated Types

Loading content...

Required methods

fn cat(&self, tensors: &[&Self::TensorType], dim: usize) -> Self::TensorType

fn chunk(&self, chunks: usize, dim: usize) -> Vec<Self::TensorType>

fn gather(&self, dim: usize, index: &Self::TensorType) -> Self::TensorType

fn index_select(&self, dim: usize, index: &Self::TensorType) -> Self::TensorType

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

fn split(&self, sections: &[usize], dim: usize) -> Vec<Self::TensorType>

fn squeeze(&self, dim: Option<usize>) -> Self::TensorType

fn stack(tensors: &[&Self], dim: usize) -> Self::TensorType

fn take(&self, index: &[usize]) -> Self::TensorType

fn permute(&self, dims: &[usize]) -> Self::TensorType

fn unsqueeze(&self, dim: usize) -> Self::TensorType

fn conditional_select(
    &self,
    x: &Self::TensorType,
    y: &Self::TensorType
) -> Self::TensorType

fn repeat(&self, sizes: &[usize]) -> Self::TensorType

Loading content...

Implementors

impl<T> IndexSlicing for GenTensor<T> where
    T: Float
[src]

type TensorType = GenTensor<T>

fn cat(&self, tensors: &[&Self::TensorType], dim: usize) -> Self::TensorType[src]

Concatenates the given sequence of seq tensors in the given dimension.

fn chunk(&self, chunks: usize, dim: usize) -> Vec<Self::TensorType>[src]

Splits a tensor into a specific number of chunks.

fn split(&self, sections: &[usize], dim: usize) -> Vec<Self::TensorType>[src]

Splits the tensor into chunks. Each chunk is a view of the original tensor.

fn stack(tensors: &[&Self], dim: usize) -> Self::TensorType[src]

Concatenates sequence of tensors along a new dimension.

All tensors need to be of the same size.

let m1 = GenTensor::<f64>::new_raw(&vec![1.,2.,3.,4.,5.,6.], &vec![3,2]);
let m2 = GenTensor::<f64>::new_raw(&vec![2.,3.,4.,5.,6.,7.], &vec![3,2]);
let result = GenTensor::<f64>::stack(&vec![&m1, &m2], 1);
let raw = result.get_raw();
for i in raw {
    println!("{}", i);
}
assert_eq!(*result.size(), vec![3,2,2]);

fn take(&self, index: &[usize]) -> Self::TensorType[src]

Returns a new tensor with the elements of input at the given indices. The input tensor is treated as if it were viewed as a 1-D tensor. The result takes the same shape as the indices.

fn permute(&self, dims: &[usize]) -> Self::TensorType[src]

Permute the dimensions of this tensor.

let mut m1 = GenTensor::<f64>::fill(1., &vec![2, 3, 5]);
m1.permute(&vec![2, 0, 1]);
Loading content...