pub struct SharedBatchSizes { /* private fields */ }
Expand description
Slice of a reference-counted batch sizes vector.
The value of the i
th index of the batch sizes vector is the number of sequences with length
at least i + 1
. It is the number of index-i
steps that appear in the packed tensor.
Implementations§
Sourcepub fn from_batch_sizes<I: IntoIterator<Item = usize>>(
batch_sizes: I,
) -> Result<Self, PackingError>
pub fn from_batch_sizes<I: IntoIterator<Item = usize>>( batch_sizes: I, ) -> Result<Self, PackingError>
Construct from an iterator of monotonic decreasing batch sizes.
Returns an error if any batch size is greater than the previous batch size.
Sourcepub fn from_sorted_sequence_lengths<I: IntoIterator<Item = usize>>(
lengths: I,
) -> Result<Self, PackingError>
pub fn from_sorted_sequence_lengths<I: IntoIterator<Item = usize>>( lengths: I, ) -> Result<Self, PackingError>
Construct from an iterator of monotonic decreasing sequence lengths.
Returns an error if any length is greater than the previous length.
Sourcepub fn tensor(&self) -> Tensor
pub fn tensor(&self) -> Tensor
Batch size as an i64
[Tensor]
. The underlying data is cached and shared between calls.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The total number of elements across all sequences represented by this structure.
Trait Implementations§
Source§fn clone(&self) -> SharedBatchSizes
fn clone(&self) -> SharedBatchSizes
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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