Packed Sequences

opacus.utils.packed_sequences.compute_seq_lengths(batch_sizes)[source]

Computes the sequence lengths of a PackedSequence represented with batch_sizes.

Parameters:

batch_sizes (Tensor) – Contains the batch sizes as stored in a PackedSequence

Returns:

the length parameter used in the torch.nn.utils.rnn.packed_padded_sequence function to create a PackedSequence. It’s a list of the same length as batch_sizes.

Return type:

running_seq_lengths