Skip to main content

TensorDescriptorExt

Trait TensorDescriptorExt 

Source
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§

Source

fn numel(&self) -> usize

Total number of elements in the tensor (product of shape).

Source

fn ndim(&self) -> usize

Number of dimensions (rank).

Source

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.

Source

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).

Source

fn cuda_device_id(&self) -> Option<usize>

Returns the CUDA device ID if the tensor is on a CUDA device.

Implementors§