pub enum DynTensor<D: Device> {
Float(Tensor<D, Float>),
Int(Tensor<D, Int>),
Bool(Tensor<D, Bool>),
}Expand description
A tensor whose kind (Float/Int/Bool) is determined at runtime.
This is the type-erased counterpart to Tensor<D, K>. Use it when you need
to store or pass tensors of different kinds together — most importantly for
disk I/O (from_bytes / to_bytes).
Variants§
Implementations§
Source§impl<D: Device> DynTensor<D>
impl<D: Device> DynTensor<D>
Sourcepub fn into_float(self) -> Result<Tensor<D, Float>>
pub fn into_float(self) -> Result<Tensor<D, Float>>
Unwrap into a Float tensor, or error.
Source§impl<D: Device> DynTensor<D>
impl<D: Device> DynTensor<D>
Sourcepub fn from_bytes(
bytes: &[u8],
dtype: DType,
shape: impl Into<Shape>,
device: &D,
) -> Result<Self>
pub fn from_bytes( bytes: &[u8], dtype: DType, shape: impl Into<Shape>, device: &D, ) -> Result<Self>
Create a DynTensor from raw little-endian bytes and a runtime DType.
This is the primary entry point for deserialization (safetensors, NPY, …).
The byte slice length must equal shape.element_count() * dtype.size_in_bytes().
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for DynTensor<D>
impl<D> RefUnwindSafe for DynTensor<D>
impl<D> Send for DynTensor<D>
impl<D> Sync for DynTensor<D>
impl<D> Unpin for DynTensor<D>
impl<D> UnsafeUnpin for DynTensor<D>
impl<D> UnwindSafe for DynTensor<D>
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