pub struct SeqTensor {
pub dtype: DataType,
pub shape: Vec<usize>,
pub layout: TensorLayout,
/* private fields */
}Expand description
An immutable tensor view used as one sequence element.
Cloning this type only bumps the backing allocation’s Arc count. Shape,
strides, and byte offset are metadata, so a split slice can share the source
allocation even when it is not contiguous.
Fields§
§dtype: DataType§shape: Vec<usize>§layout: TensorLayoutImplementations§
Source§impl SeqTensor
impl SeqTensor
Sourcepub fn new(tensor: Tensor) -> Self
pub fn new(tensor: Tensor) -> Self
Wrap an existing session tensor in an immutable shared handle.
Sourcepub fn from_raw(
dtype: DataType,
shape: Vec<usize>,
bytes: &[u8],
) -> SequenceResult<Self>
pub fn from_raw( dtype: DataType, shape: Vec<usize>, bytes: &[u8], ) -> SequenceResult<Self>
Build a host tensor from raw element bytes and share it as a sequence item.
Whether two handles share the same underlying device allocation.
Sourcepub fn storage_strong_count(&self) -> usize
pub fn storage_strong_count(&self) -> usize
Number of live handles to the shared allocation.
Sourcepub fn byte_offset(&self) -> usize
pub fn byte_offset(&self) -> usize
Byte offset of this view’s logical origin from Self::as_ptr.
pub fn device(&self) -> DeviceId
pub fn numel(&self) -> usize
Sourcepub fn contiguous_bytes(&self) -> SequenceResult<Vec<u8>>
pub fn contiguous_bytes(&self) -> SequenceResult<Vec<u8>>
Materialize this logical tensor as contiguous host bytes.
Sourcepub fn as_bytes(&self) -> SequenceResult<&[u8]>
pub fn as_bytes(&self) -> SequenceResult<&[u8]>
Borrow bytes directly when this is a contiguous host view.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SeqTensor
impl !UnwindSafe for SeqTensor
impl Freeze for SeqTensor
impl Send for SeqTensor
impl Sync for SeqTensor
impl Unpin for SeqTensor
impl UnsafeUnpin for SeqTensor
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