pub trait NdArray {
// Required methods
fn shape(&self) -> Result<Shape>;
fn to_cpu_storage(&self) -> HostBuffer;
}Expand description
Trait for host array-like values that describe their shape and yield CPU storage.
Implemented for scalars, arrays, slices, and nested vecs up to 4 dimensions.
It lets array-like Rust values report the Shape their data describes and
materialize into a HostBuffer — the raw material a lazy tensor is built from.
§Example
use fuel_tensor::NdArray;
// Scalars, arrays, and nested arrays all implement `NdArray` and report
// the shape their data describes.
assert_eq!(3.14f32.shape()?.dims(), &[] as &[usize]);
assert_eq!((&[1f32, 2., 3.]).shape()?.dims(), &[3]);
assert_eq!((&[[1f32, 2.], [3., 4.]]).shape()?.dims(), &[2, 2]);Required Methods§
Sourcefn to_cpu_storage(&self) -> HostBuffer
fn to_cpu_storage(&self) -> HostBuffer
Converts this value into CPU storage.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".