pub trait TensorManipulationExt<T: TensorElement> {
// Required methods
fn squeeze_all(&self) -> Result<Tensor<T>>;
fn squeeze_dims(&self, dims: &[i32]) -> Result<Tensor<T>>;
fn unsqueeze_dims(&self, dims: &[i32]) -> Result<Tensor<T>>;
fn add_batch_dim(&self) -> Result<Tensor<T>>;
fn remove_batch_dim(&self) -> Result<Tensor<T>>;
fn atleast_nd(&self, n: usize) -> Result<Tensor<T>>;
fn to_channel_last(&self) -> Result<Tensor<T>>;
fn to_channel_first(&self) -> Result<Tensor<T>>;
fn swap_dims(&self, dim0: i32, dim1: i32) -> Result<Tensor<T>>;
fn move_dim(&self, src: i32, dst: i32) -> Result<Tensor<T>>;
fn expand_to(&self, target_shape: &[usize]) -> Result<Tensor<T>>;
fn repeat_along(&self, dim: i32, repeats: usize) -> Result<Tensor<T>>;
}Expand description
Extension trait for advanced tensor manipulation
Required Methods§
Sourcefn squeeze_all(&self) -> Result<Tensor<T>>
fn squeeze_all(&self) -> Result<Tensor<T>>
Squeeze all dimensions of size 1
Sourcefn squeeze_dims(&self, dims: &[i32]) -> Result<Tensor<T>>
fn squeeze_dims(&self, dims: &[i32]) -> Result<Tensor<T>>
Squeeze specific dimensions
Sourcefn unsqueeze_dims(&self, dims: &[i32]) -> Result<Tensor<T>>
fn unsqueeze_dims(&self, dims: &[i32]) -> Result<Tensor<T>>
Unsqueeze at multiple positions
Sourcefn add_batch_dim(&self) -> Result<Tensor<T>>
fn add_batch_dim(&self) -> Result<Tensor<T>>
Add a batch dimension at the front
Sourcefn remove_batch_dim(&self) -> Result<Tensor<T>>
fn remove_batch_dim(&self) -> Result<Tensor<T>>
Remove the batch dimension (first dimension)
Sourcefn atleast_nd(&self, n: usize) -> Result<Tensor<T>>
fn atleast_nd(&self, n: usize) -> Result<Tensor<T>>
Ensure tensor has at least N dimensions (add trailing dimensions)
Sourcefn to_channel_last(&self) -> Result<Tensor<T>>
fn to_channel_last(&self) -> Result<Tensor<T>>
Transpose to channel-last format (NCHW -> NHWC)
Sourcefn to_channel_first(&self) -> Result<Tensor<T>>
fn to_channel_first(&self) -> Result<Tensor<T>>
Transpose to channel-first format (NHWC -> NCHW)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".