Packs a Tensor containing padded sequences of variable length.
input can be of size (if is )
or (if is ) where is the length
of the longest sequence, is the batch size, and is any number of dimensions
(including 0).
T
x
B
x
*
batch_first
False
BxTx*
batch_first
True
T
B
*
For unsorted sequences, use enforce_sorted = False. If enforce_sorted is
True, the sequences should be sorted by length in a decreasing order, i.e.
input[:,0] should be the longest sequence, and input[:,B-1] the shortest
one. enforce_sorted = True is only necessary for ONNX export.
input (Tensor) – padded batch of variable length sequences.
lengths (Tensor or list(int)) – list of sequence lengths of each batch
element (must be on the CPU if provided as a tensor).
batch_first (bool, optional) – if True, the input is expected in BxTx*
format, TxBx* otherwise. Default: False.
enforce_sorted (bool, optional) – if True, the input is expected to
contain sequences sorted by length in a decreasing order. If
False, the input will get sorted unconditionally. Default: True.