def makeEmbedBatch(self, xs, reverse=False):
if reverse:
xs = [xp.asarray(x[::-1], dtype=xp.int32) for x in xs]
elif not reverse:
# xs = xp.asarray(xs,dtype=xp.int32)
xs = [xp.asarray(x, dtype=xp.int32) for x in xs]
section_pre = np.array([len(x) for x in xs[:-1]], dtype=np.int32)
sections = np.cumsum(section_pre) # CuPy does not have cumsum()
xs = F.split_axis(self.embed(F.concat(xs, axis=0)), sections, axis=0)
return xs
评论列表
文章目录