The original definition of InsertEmbedding
refers to here.
The difference between dynamic_batching.InsertEmbedding
and InsertEmbedding
is that the sequence length, offset of each batch are different.
dynamic_batching.InsertEmbedding
uses seqstarts
, outstarts
, and patstarts
to record the sequence begining position of each batch.
Input sequences.
Shape:
patch sequences.
Shape:
seqstarts[:batch]
contains the position of the first token in X
and for each batch.
And seqstarts[batch]
contains the total length of X
.
Note that seqstarts[b+1]-seqstarts[b]
can calculate out the sequence length of batch
Shape:
outstarts[:batch]
contains the position of the first token in Y
and for each batch.
And outstarts[batch]
contains the total length of Y
.
Note that outstarts[b+1]-outstarts[b]
can calculate out the sequence length of batch
Usually, outstarts[-1]=seqstarts[-1]+patstarts[-1]
or outstarts[-1]=seqstarts[-1]+batch*patstarts[-1]
when
Shape:
patstarts[:batch]
contains the position of the first token in P
and for each batch.
And patstarts[batch]
contains the total length of P
.
Note that patstarts[b+1]-patstarts[b]
can calculate out the sequence length of batch
When size of patstarts
is
Shape:
Insert offset.
Shape:
Maximum sequence length of Y
, equal to max(outstarts[1:]-outstarts[:batch])
. For parallel computing.
Output sequences.
Shape: