pub trait IndexSlicingwhere
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§
Sourcefn cat(&self, tensors: &[Self], dim: usize) -> Self
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).
Sourcefn chunk(&self, chunks: usize, dim: usize) -> Vec<Self>
fn chunk(&self, chunks: usize, dim: usize) -> Vec<Self>
Splits a tensor into a specific number of chunks.
Sourcefn gather(&self, dim: usize, index: &Self) -> Self
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.
Sourcefn spread(&self, dim: usize, index: &Self, value: &Self) -> Self
fn spread(&self, dim: usize, index: &Self, value: &Self) -> Self
The opposite of gather. Self will be replaced with value along dim by index.
Sourcefn 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.
Sourcefn 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.
Sourcefn split(&self, sections: &[usize], dim: usize) -> Vec<Self>
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.
Sourcefn stack(&self, tensors: &[Self], dim: usize) -> Self
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.
Sourcefn take(&self, index: &[usize]) -> Self
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.
Sourcefn 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.
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.