replace with tensor op (#3099)

This commit is contained in:
SnakeOnex
2024-01-12 14:13:40 -05:00
committed by GitHub
parent f3a50b4e40
commit 0c49d38ba7
+1 -1
View File
@@ -51,7 +51,7 @@ class Transformer:
maxlen_eye = Tensor.eye(x.shape[1])
maxlen_eye = maxlen_eye.unsqueeze(0).expand([bs, *maxlen_eye.shape])
onehot_feat = x[:, :, None] == Tensor.arange(self.syms).reshape((1,1) + (self.syms,))
onehot_feat = x.one_hot(self.syms)
onehot = maxlen_eye.cat(onehot_feat, dim=2).flatten(end_dim=1)