Skip to content

Commit

Permalink
swap order in rsqrt
Browse files Browse the repository at this point in the history
fixed backward for 0
  • Loading branch information
chenyuxyz committed Feb 13, 2025
1 parent 49abc09 commit f8c89ee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions test/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,7 @@ def test_sqrt(self):
helper_test_op([()], lambda x: x.sqrt())
def test_rsqrt(self):
helper_test_op([(45,65)], lambda x: x.rsqrt())
# TODO: fix backward
helper_test_op(None, lambda x: x.rsqrt(), vals=[[0.0]], forward_only=True)
helper_test_op(None, lambda x: x.rsqrt(), vals=[[0.0]])
helper_test_op([()], lambda x: x.rsqrt())

def test_xor(self):
Expand Down
2 changes: 1 addition & 1 deletion tinygrad/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2652,7 +2652,7 @@ def rsqrt(self):
print(Tensor([1., 2., 3., 4.]).rsqrt().numpy())
```
"""
return self.reciprocal().sqrt()
return self.sqrt().reciprocal()
def sin(self):
"""
Computes the sine of the tensor element-wise.
Expand Down

0 comments on commit f8c89ee

Please sign in to comment.