Trait IndexSlicing

Source
pub trait IndexSlicing
where Self: Sized,
{
Show 16 methods // Required methods fn cat(&self, tensors: &[Self], dim: usize) -> Self; fn chunk(&self, chunks: usize, dim: usize) -> Vec<Self>; fn gather(&self, dim: usize, index: &Self) -> Self; fn spread(&self, dim: usize, index: &Self, value: &Self) -> Self; fn index_select(&self, dim: usize, index: &Self) -> Self; fn index_exclude(&self, dim: usize, index: &Self) -> Self; fn reshape(&self, new_shape: &[usize]) -> Self; fn split(&self, sections: &[usize], dim: usize) -> Vec<Self>; fn squeeze(&self, dim: Option<usize>) -> Self; fn stack(&self, tensors: &[Self], dim: usize) -> Self; fn t(&self) -> Self; fn take(&self, index: &[usize]) -> Self; fn permute(&self, dims: &[usize]) -> Self; fn unsqueeze(&self, dim: usize) -> Self; fn conditional_select(&self, x: &Self, y: &Self) -> Self; fn repeat(&self, sizes: &[usize]) -> Self;
}

Required Methods§

Source

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

Concatenates the given sequence of seq tensors in the given dimension. The input tensor should all have the same size except on the given dimension. The output tensor will have all the same size as the input except the given dimension, which will be the sum of the inputs on the given dimension. Apply cat on [tensor(5, 3, 2), tensor(5, 7, 2), ] will get a tensor(5, 10, 2).

Source

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

Splits a tensor into a specific number of chunks.

Source

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

Pick elements on the given dimension by the index, and gather them in the output. A restriction is that self.size() and index.size() should be the same on other dimensions.

Source

fn spread(&self, dim: usize, index: &Self, value: &Self) -> Self

The opposite of gather. Self will be replaced with value along dim by index.

Source

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

Select on dim and collect those subtensor by index.

Source

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

Inverse of index_select, remove those subtensor by index along dim.

Source

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

Just change the index boundary.

Source

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

Inverse of cat(), split tensor along dim dimension, the length of each section on dim is specified by sections.

Source

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

Remove dimension with length of 1.

Source

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

Stack tensor with the same size along a new dimension specified by dim. The difference from cat is that cat don’t create new dimension.

Source

fn t(&self) -> Self

Transpose

Source

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

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.

Source

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

Source

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

Add size 1 dimension at dim.

Source

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

Self is the bool condition, at each position of self, select from x if self at the position is positive or zero, Otherwise , use value from y if self at the position is negative. The restriction is that, self, x, and y all have the same size.

Source

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

Repeat the tensor along all dimensions, the number of repeat is specified in sizes. Thus the restriction is that self.size().len() is equal to sizes.len().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> IndexSlicing for GenTensor<T>
where T: Float,