|
|
@ -147,7 +147,7 @@ def make_pad_mask(lengths, xs=None, length_dim=-1):
|
|
|
|
seq_range = paddle.arange(0, maxlen, dtype=paddle.int64)
|
|
|
|
seq_range = paddle.arange(0, maxlen, dtype=paddle.int64)
|
|
|
|
seq_range_expand = seq_range.unsqueeze(0).expand([bs, maxlen])
|
|
|
|
seq_range_expand = seq_range.unsqueeze(0).expand([bs, maxlen])
|
|
|
|
seq_length_expand = lengths.unsqueeze(-1)
|
|
|
|
seq_length_expand = lengths.unsqueeze(-1)
|
|
|
|
mask = seq_range_expand >= seq_length_expand
|
|
|
|
mask = seq_range_expand >= seq_length_expand.cast(seq_range_expand.dtype)
|
|
|
|
|
|
|
|
|
|
|
|
if xs is not None:
|
|
|
|
if xs is not None:
|
|
|
|
assert paddle.shape(xs)[0] == bs, (paddle.shape(xs)[0], bs)
|
|
|
|
assert paddle.shape(xs)[0] == bs, (paddle.shape(xs)[0], bs)
|
|
|
|