Trait tensor_rs::tensor_trait::index_slicing::IndexSlicing
source · [−]pub trait IndexSlicing where
Self: Sized, {
Show 15 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 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
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).
Splits a tensor into a specific number of chunks.
Pick elements on the given dimension by the index given in index, and gather them in the output. A restriction is that self size and index size should be the same.
fn index_select(&self, dim: usize, index: &Self) -> Self
fn index_select(&self, dim: usize, index: &Self) -> Self
Select on dim and collect those subtensor by index.
fn index_exclude(&self, dim: usize, index: &Self) -> Self
fn index_exclude(&self, dim: usize, index: &Self) -> Self
Inverse of index_select, remove those subtensor by index along dim.
Inverse of cat(), split tensor along dim dimension, the length of each section on dim is specified by sections.
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.
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 conditional_select(&self, x: &Self, y: &Self) -> Self
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.