add comment

pull/3912/head
enkilee 10 months ago
parent 6c2652eb7e
commit 95d97255f1

@ -120,6 +120,7 @@ class SinusoidalPosEmb(nn.Layer):
self.dim = dim
def forward(self, x: paddle.Tensor):
# check if x is 0-dim tensor, if so, add a dimension
if x.ndim == 0:
x = paddle.cast(x.unsqueeze(0), 'float32')
else:

@ -181,6 +181,7 @@ def make_pad_mask(lengths, xs=None, length_dim=-1):
if length_dim == 0:
raise ValueError("length_dim cannot be 0: {}".format(length_dim))
# check if lengths is 0-dim tensor, if so, add a dimension
if lengths.ndim == 0:
bs = paddle.shape(lengths.unsqueeze(0))
else:

Loading…
Cancel
Save