pub enum TensorLayout {
Nchw,
Nhwc,
Ncdhw,
Ndhwc,
RowMajor,
}Expand description
Memory layout convention for multi-dimensional tensors.
The layout determines how logical indices map to linear memory offsets. NHWC layouts are generally preferred on modern NVIDIA GPUs because they enable Tensor Core utilisation, while NCHW is the traditional PyTorch default.
Variants§
Nchw
Batch, Channels, Height, Width – PyTorch default.
Nhwc
Batch, Height, Width, Channels – Tensor Core optimal.
Ncdhw
Batch, Channels, Depth, Height, Width – 3-D volumetric.
Ndhwc
Batch, Depth, Height, Width, Channels – 3-D channels-last.
RowMajor
Generic row-major layout for 2-D tensors (matrices) and MoE intermediates.
Implementations§
Source§impl TensorLayout
impl TensorLayout
Sourcepub const fn spatial_dims(self) -> usize
pub const fn spatial_dims(self) -> usize
Returns the number of spatial dimensions implied by this layout.
Sourcepub const fn expected_ndim(self) -> usize
pub const fn expected_ndim(self) -> usize
Returns the expected number of tensor dimensions (including N and C).
Sourcepub const fn is_channels_last(self) -> bool
pub const fn is_channels_last(self) -> bool
Returns true if this layout places channels last (NHWC or NDHWC).
Trait Implementations§
Source§impl Clone for TensorLayout
impl Clone for TensorLayout
Source§fn clone(&self) -> TensorLayout
fn clone(&self) -> TensorLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TensorLayout
Source§impl Debug for TensorLayout
impl Debug for TensorLayout
impl Eq for TensorLayout
Source§impl Hash for TensorLayout
impl Hash for TensorLayout
Source§impl PartialEq for TensorLayout
impl PartialEq for TensorLayout
Source§fn eq(&self, other: &TensorLayout) -> bool
fn eq(&self, other: &TensorLayout) -> bool
self and other values to be equal, and is used by ==.