dynamic_batching.PositionIndex, uses seqstarts to record the sequence begining position of each batch.
Generating tokens' position indeces of each batch
input sequences
Shape: seqstarts[batch]
seqstarts[:batch] contains the position of the first token in sequences of each batch. And seqstarts[batch] contains the total length of sequences.
Note that seqstarts[b+1]-seqstarts[b] can calculate out the sequence length of batch
Shape:
Sequence position of each batch.
Shape:
Maximum sequence length of sequences, equal to max(seqstarts[1:]-seqstarts[:batch]). For parallel computing.
Shape: seqstarts[batch]