UnaryOps.NEG (#1749)

This commit is contained in:
George Hotz
2023-09-03 12:44:26 -07:00
committed by GitHub
parent 9f1a54acee
commit e17b1af160
10 changed files with 20 additions and 8 deletions

View File

@@ -534,6 +534,7 @@ class Tensor:
# ***** mlops (unary) *****
def __neg__(self): return mlops.Neg.apply(self)
def contiguous(self): return mlops.Contiguous.apply(self)
def contiguous_backward(self): return mlops.ContiguousBackward.apply(self)
def log(self): return mlops.Log.apply(self)
@@ -557,7 +558,6 @@ class Tensor:
def ceil(self: Tensor) -> Tensor: return (self > (b := self.trunc())).where(b+1, b)
def floor(self: Tensor) -> Tensor: return (self < (b := self.trunc())).where(b-1, b)
def __neg__(self): return 0.0-self
def square(self): return self*self
def clip(self, min_, max_): return self.maximum(min_).minimum(max_)
def abs(self): return self.relu() + (-self).relu()