pub struct LogicalTensor { /* private fields */ }Expand description
Backend-free, dtype-preserving logical host tensor in column-major order.
Use CpuExecutionContext::reconstruct in the receiving execution domain.
The adapter, not tensor4all, owns serialization and transport.
§Examples
use tensor4all_tensorbackend::{LogicalTensor, LogicalTensorData};
let tensor = LogicalTensor::new(
vec![2, 2],
LogicalTensorData::F64(vec![1.0, 2.0, 3.0, 4.0]),
)?;
assert_eq!(tensor.shape(), &[2, 2]);
assert_eq!(tensor.data().len(), 4);Implementations§
Source§impl LogicalTensor
impl LogicalTensor
Sourcepub fn new(
shape: Vec<usize>,
data: LogicalTensorData,
) -> Result<Self, LogicalTensorError>
pub fn new( shape: Vec<usize>, data: LogicalTensorData, ) -> Result<Self, LogicalTensorError>
Create a validated column-major logical tensor snapshot.
§Errors
Returns LogicalTensorError::ShapeOverflow when the shape product
overflows, or LogicalTensorError::ElementCountMismatch when the data
length differs from that product.
Sourcepub fn from_native(tensor: &Tensor) -> Result<Self, LogicalTensorError>
pub fn from_native(tensor: &Tensor) -> Result<Self, LogicalTensorError>
Snapshot a native host tensor without retaining execution identity.
§Errors
Returns LogicalTensorError::Tensor if the native tensor is not
host-readable with its declared dtype.
Sourcepub fn data(&self) -> &LogicalTensorData
pub fn data(&self) -> &LogicalTensorData
Return the owned scalar payload.
Trait Implementations§
Source§impl Clone for LogicalTensor
impl Clone for LogicalTensor
Source§fn clone(&self) -> LogicalTensor
fn clone(&self) -> LogicalTensor
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 LogicalTensor
impl Debug for LogicalTensor
Source§impl PartialEq for LogicalTensor
impl PartialEq for LogicalTensor
Source§fn eq(&self, other: &LogicalTensor) -> bool
fn eq(&self, other: &LogicalTensor) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for LogicalTensor
Auto Trait Implementations§
impl Freeze for LogicalTensor
impl RefUnwindSafe for LogicalTensor
impl Send for LogicalTensor
impl Sync for LogicalTensor
impl Unpin for LogicalTensor
impl UnsafeUnpin for LogicalTensor
impl UnwindSafe for LogicalTensor
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,
impl<T, U> Imply<T> for U
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