pull/3912/head
enkilee 10 months ago
parent dfbce6cd87
commit 8515d64363

@ -120,8 +120,7 @@ class SinusoidalPosEmb(nn.Layer):
self.dim = dim
def forward(self, x: paddle.Tensor):
x = paddle.cast(x, 'float32')
x = x.unsqueeze(0)
x = paddle.cast(x.unsqueeze(0), 'float32')
half_dim = self.dim // 2
emb = math.log(10000) / (half_dim - 1)
emb = paddle.exp(paddle.arange(half_dim) * -emb)

@ -180,8 +180,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))
lengths = lengths.unsqueeze(0)
bs = paddle.shape(lengths)
bs = paddle.shape(lengths.unsqueeze(0))
if xs is None:
maxlen = paddle.cast(lengths.max(), dtype=bs.dtype)
else:

Loading…
Cancel
Save