mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-09-01 07:46:07 +00:00
replace with tensor op (#3099)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user