pub trait TensorDescriptorExt: TensorDescriptor {
// Provided methods
fn numel(&self) -> usize { ... }
fn ndim(&self) -> usize { ... }
fn is_contiguous(&self) -> bool { ... }
fn contiguous_stride(&self) -> Vec<usize> { ... }
fn cuda_device_id(&self) -> Option<usize> { ... }
}Expand description
Extension trait providing helper methods for tensor descriptors.
Provided Methods§
Sourcefn is_contiguous(&self) -> bool
fn is_contiguous(&self) -> bool
Check if tensor is contiguous in memory (row-major/C order).
A tensor is contiguous if its strides follow the pattern where the last dimension has stride 1, and each preceding dimension has stride equal to the product of all following dimensions.
Sourcefn contiguous_stride(&self) -> Vec<usize>
fn contiguous_stride(&self) -> Vec<usize>
Compute the contiguous stride for the current shape.
Returns the stride that would make this tensor contiguous (row-major/C order).
Sourcefn cuda_device_id(&self) -> Option<usize>
fn cuda_device_id(&self) -> Option<usize>
Returns the CUDA device ID if the tensor is on a CUDA device.