pub enum NdArrayTensor {
F64(NdArrayStorage<f64>),
F32(NdArrayStorage<f32>),
I64(NdArrayStorage<i64>),
I32(NdArrayStorage<i32>),
I16(NdArrayStorage<i16>),
I8(NdArrayStorage<i8>),
U64(NdArrayStorage<u64>),
U32(NdArrayStorage<u32>),
U16(NdArrayStorage<u16>),
U8(NdArrayStorage<u8>),
Bool(NdArrayStorage<bool>),
}burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
Expand description
Tensor primitive used by the ndarray backend.
Supports both owned and borrowed (zero-copy) data via NdArrayStorage.
When data is borrowed from external sources (like burnpack files),
it remains zero-copy until a mutating operation is performed.
Variants§
F64(NdArrayStorage<f64>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
F32(NdArrayStorage<f32>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
I64(NdArrayStorage<i64>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
I32(NdArrayStorage<i32>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
I16(NdArrayStorage<i16>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
I8(NdArrayStorage<i8>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
U64(NdArrayStorage<u64>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
U32(NdArrayStorage<u32>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
U16(NdArrayStorage<u16>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
U8(NdArrayStorage<u8>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
Bool(NdArrayStorage<bool>)
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
Implementations§
Source§impl NdArrayTensor
impl NdArrayTensor
Sourcepub fn is_borrowed(&self) -> bool
👎Deprecated since 0.22.0: burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
pub fn is_borrowed(&self) -> bool
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
Returns true if this tensor uses borrowed (zero-copy) storage.
Source§impl NdArrayTensor
impl NdArrayTensor
Sourcepub fn from_data(data: TensorData) -> NdArrayTensor
👎Deprecated since 0.22.0: burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
pub fn from_data(data: TensorData) -> NdArrayTensor
burn-ndarray is deprecated and will be removed in a future release. Use burn-flex for pure-Rust CPU execution (std, no_std, WebAssembly), or one of the CubeCL backends (burn-cuda, burn-rocm, burn-wgpu, burn-cpu) for GPU acceleration.
Create a new ndarray tensor from data.
This method attempts zero-copy loading when possible. If the data has properly aligned bytes that can be borrowed, it creates a borrowed tensor. Otherwise, it falls back to copying the data.
Zero-copy loading works when:
- The data’s bytes are properly aligned for the element type
- The bytes can be borrowed (e.g., from mmap’d file or static data)
Trait Implementations§
Source§impl Clone for NdArrayTensor
impl Clone for NdArrayTensor
Source§fn clone(&self) -> NdArrayTensor
fn clone(&self) -> NdArrayTensor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NdArrayTensor
impl Debug for NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<bool>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<bool>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<bool>) -> NdArrayTensor
fn from(value: SharedArray<bool>) -> NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<f32>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<f32>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<f32>) -> NdArrayTensor
fn from(value: SharedArray<f32>) -> NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<f64>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<f64>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<f64>) -> NdArrayTensor
fn from(value: SharedArray<f64>) -> NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<i8>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<i8>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<i8>) -> NdArrayTensor
fn from(value: SharedArray<i8>) -> NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<i16>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<i16>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<i16>) -> NdArrayTensor
fn from(value: SharedArray<i16>) -> NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<i32>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<i32>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<i32>) -> NdArrayTensor
fn from(value: SharedArray<i32>) -> NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<i64>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<i64>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<i64>) -> NdArrayTensor
fn from(value: SharedArray<i64>) -> NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<u8>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<u8>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<u8>) -> NdArrayTensor
fn from(value: SharedArray<u8>) -> NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<u16>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<u16>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<u16>) -> NdArrayTensor
fn from(value: SharedArray<u16>) -> NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<u32>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<u32>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<u32>) -> NdArrayTensor
fn from(value: SharedArray<u32>) -> NdArrayTensor
Source§impl From<ArrayBase<OwnedArcRepr<u64>, Dim<IxDynImpl>>> for NdArrayTensor
impl From<ArrayBase<OwnedArcRepr<u64>, Dim<IxDynImpl>>> for NdArrayTensor
Source§fn from(value: SharedArray<u64>) -> NdArrayTensor
fn from(value: SharedArray<u64>) -> NdArrayTensor
Source§impl TensorMetadata for NdArrayTensor
impl TensorMetadata for NdArrayTensor
Source§type Device = NdArrayDevice
type Device = NdArrayDevice
Source§fn device(&self) -> NdArrayDevice
fn device(&self) -> NdArrayDevice
Source§fn can_mut(&self) -> bool
fn can_mut(&self) -> bool
slice_assign, an inplace kernel)
writes the existing allocation instead of copying it first. Read moreSource§fn scheme(&self) -> QuantScheme
fn scheme(&self) -> QuantScheme
Auto Trait Implementations§
impl !RefUnwindSafe for NdArrayTensor
impl !UnwindSafe for NdArrayTensor
impl Freeze for NdArrayTensor
impl Send for NdArrayTensor
impl Sync for NdArrayTensor
impl Unpin for NdArrayTensor
impl UnsafeUnpin for NdArrayTensor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more