Skip to content

Commit

Permalink
Revert "simpler abs and sign (tinygrad#4606)" (tinygrad#4608)
Browse files Browse the repository at this point in the history
This reverts commit a5e157f.
  • Loading branch information
chenyuxyz authored May 15, 2024
1 parent a5e157f commit 8694eeb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tinygrad/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,8 @@ def round(self: Tensor) -> Tensor:
def lerp(self, end: Tensor, weight: Union[Tensor, float]) -> Tensor: return self + (end - self) * weight
def square(self): return self*self
def clip(self, min_, max_): return self.maximum(min_).minimum(max_)
def abs(self): return (self < 0).detach().where(-self, self)
def sign(self): return (self == 0).detach().where(0, self / self.abs()).cast(self.dtype)
def abs(self): return self.relu() + (-self).relu()
def sign(self): return ((self.float()) / (self.float().abs() + 1e-12)).cast(self.dtype)
def reciprocal(self): return F.Reciprocal.apply(self.cast(least_upper_float(self.dtype)))

# ***** activation functions (unary) *****
Expand Down

0 comments on commit 8694eeb

Please sign in to comment.