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§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<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<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<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 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.
Auto Trait Implementations§
impl Freeze for NdArrayTensor
impl !RefUnwindSafe for NdArrayTensor
impl Send for NdArrayTensor
impl Sync for NdArrayTensor
impl Unpin for NdArrayTensor
impl !UnwindSafe for NdArrayTensor
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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