mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-02-19 02:44:40 -05:00
Slice migrated in Eye op (#1281)
* Migrated from slice to pad and shrink, made cleaner * Changed repeat with reshape and expand
This commit is contained in:
@@ -168,7 +168,9 @@ class Tensor:
|
||||
def ones_like(tensor, **kwargs): return Tensor.full_like(tensor, 1, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def eye(dim, **kwargs): return Tensor([1], **kwargs).slice(((0,dim+1),)).reshape(1, dim+1).expand(dim, dim+1).reshape(dim*(dim+1)).slice(((0,dim*dim),)).reshape(dim, dim)
|
||||
def eye(dim:int, **kwargs):
|
||||
return Tensor([1], **kwargs).pad(((0,dim),)).reshape(1, dim+1).expand(dim, dim+1).reshape(dim*(dim+1)).shrink(((0,dim*dim),)).reshape(dim, dim)
|
||||
|
||||
|
||||
# ***** rng hlops *****
|
||||
|
||||
|
||||
Reference in New Issue
Block a user