Function torch::nn::utils::rnn::pack_sequence¶
Defined in File rnn.h
Function Documentation¶
-
inline PackedSequence torch::nn::utils::rnn::pack_sequence(ArrayRef<Tensor> sequences, bool enforce_sorted = true)¶
Packs a list of variable length Tensors.
sequences
should be a list of Tensors of sizeL x *
, whereL
is the length of a sequence and*
is any number of trailing dimensions, including zero.For unsorted sequences, use
enforce_sorted = false
. Ifenforce_sorted
istrue
, the sequences should be sorted in the order of decreasing length.Arguments: sequences (torch::ArrayRef<Tensor>): A list of sequences of decreasing length. enforce_sorted (bool, optional): if
true
, checks that the input contains sequences sorted by length in a decreasing order. Iffalse
, this condition is not checked. Default:true
.Returns: a
PackedSequence
object