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>),
}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>)
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>)
Implementations§
Source§impl NdArrayTensor
impl NdArrayTensor
Sourcepub fn is_borrowed(&self) -> bool
pub fn is_borrowed(&self) -> bool
Returns true if this tensor uses borrowed (zero-copy) storage.
Source§impl NdArrayTensor
impl NdArrayTensor
Sourcepub fn from_data(data: TensorData) -> NdArrayTensor
pub fn from_data(data: TensorData) -> NdArrayTensor
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
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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
Converts to this type from the input type.
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
Converts to this type from the input type.
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
Converts to this type from the input type.
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
Converts to this type from the input type.
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
Converts to this type from the input type.
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
Converts to this type from the input type.
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
Converts to this type from the input type.
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
Converts to this type from the input type.
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
Converts to this type from the input type.
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
Converts to this type from the input type.
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
Converts to this type from the input type.
Source§impl TensorMetadata for NdArrayTensor
impl TensorMetadata for NdArrayTensor
Source§type Device = NdArrayDevice
type Device = NdArrayDevice
The device type associated with the tensor.
Source§fn device(&self) -> NdArrayDevice
fn device(&self) -> NdArrayDevice
Get the device associated with the tensor.
Source§fn can_mut(&self) -> bool
fn can_mut(&self) -> bool
Whether the tensor’s buffer can be mutated in place — i.e. this handle
uniquely owns it, so an in-place op (
slice_assign, an inplace kernel)
writes the existing allocation instead of copying it first. Read moreSource§fn scheme(&self) -> QuantScheme
fn scheme(&self) -> QuantScheme
Get the quantization scheme for a quantized float tensor. Read more
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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