pub trait Axes: Sealed { }Expand description
Axes argument of reductions and shape ops: one axis (-1, x.ndim() - 1), a list
([0, 2], &axes[..], vec![…], or a reference to any of these), all axes (..,
MLX’s axis=None) or the trailing axes from one on (1..).
An empty list means no axes, as in MLX C++ (sum(a, {})). Negative axes count from the
end. Out-of-range or repeated axes make the operation fail with
crate::OpErrorKind::InvalidAxis.
use nuvec_core::Array;
let x = Array::from_slice(&[1.0f32, 2.0, 3.0, 4.0, 5.0, 6.0], [1, 2, 3]);
assert_eq!(x.sum(-1).shape(), [1, 2]);
assert_eq!(x.sum([0, 2]).shape(), [2]);
assert_eq!(x.sum(..).shape(), [0i32; 0]);
assert_eq!(x.sum(1..).shape(), [1]);
assert_eq!(x.sum([]).shape(), [1, 2, 3]); // no axis reduced
assert_eq!(x.sum(x.ndim() - 1).shape(), [1, 2]);Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".