Skip to main content

normalize_to_data

Function normalize_to_data 

Source
pub fn normalize_to_data<T: Clone>(
    tensor: &DenseTensorData<T>,
    target: MemoryOrder,
) -> Cow<'_, DenseTensorData<T>>
Expand description

Normalize a DenseTensorData<T>’s memory order to target, with Cow::Borrowed when the tensor is already in the target order.

Use at the entry of any operation that requires a specific input layout (typically backend kernels expecting backend.preferred_order()). The returned Cow is Borrowed when no conversion is needed and Owned when a reorder was performed.