numr 0.15.2

Numerical computing and tensor library for Rust, in the role of NumPy: n-dimensional arrays, linear algebra, FFT, statistics and autograd on CPU, CUDA and 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)
}