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
sourcefn clone(&self) -> SharedBatchSizes
fn clone(&self) -> SharedBatchSizes
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourcefn 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
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
type Output = T
type Output = T
Should always be Self