numr 0.9.0

High-performance numerical computing with multi-backend GPU acceleration (CPU/CUDA/WebGPU)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Shared utilities for reduction backward implementations

use crate::error::Result;
use crate::runtime::Runtime;
use crate::tensor::Tensor;

/// Ensure a tensor is contiguous, making a copy if necessary.
///
/// Thin by-value wrapper around the crate-wide
/// [`crate::autograd::ops::ensure_contiguous`] helper, kept because callers
/// in this module pass freshly-produced owned tensors (e.g. from
/// `broadcast_to`) rather than borrows.
#[inline]
pub(super) fn ensure_contiguous<R: Runtime>(tensor: Tensor<R>) -> Result<Tensor<R>> {
    super::super::ensure_contiguous(&tensor)
}