mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-12 16:38:15 -05:00
add Tensor.log10 with test\test_ops.py::TestOps::test_log10 (#14113)
This commit is contained in:
@@ -916,6 +916,10 @@ class TestOps(unittest.TestCase):
|
||||
helper_test_op([(45,65)], torch.log, Tensor.log)
|
||||
helper_test_op(None, torch.log, Tensor.log, vals=[[math.inf, -math.inf, math.nan]])
|
||||
helper_test_op([()], torch.log, Tensor.log)
|
||||
def test_log10(self):
|
||||
helper_test_op([(45,65)], torch.log10, Tensor.log10)
|
||||
helper_test_op(None, torch.log10, Tensor.log10, vals=[[math.inf, -math.inf, math.nan]])
|
||||
helper_test_op([()], torch.log10, Tensor.log10)
|
||||
def test_log2(self):
|
||||
helper_test_op([(45,65)], torch.log2, Tensor.log2)
|
||||
helper_test_op(None, torch.log2, Tensor.log2, vals=[[math.inf, -math.inf, math.nan]])
|
||||
|
||||
@@ -2760,6 +2760,18 @@ class Tensor(OpMixin):
|
||||
"""
|
||||
return self.log2()*math.log(2)
|
||||
|
||||
def log10(self) -> Tensor:
|
||||
"""
|
||||
Computes the base-10 logarithm element-wise.
|
||||
|
||||
See: https://en.wikipedia.org/wiki/Logarithm
|
||||
|
||||
```python exec="true" source="above" session="tensor" result="python"
|
||||
print(Tensor([1., 2., 4., 8.]).log10().numpy())
|
||||
```
|
||||
"""
|
||||
return self.log2()*math.log10(2)
|
||||
|
||||
def log2(self) -> Tensor:
|
||||
"""
|
||||
Computes the base-2 logarithm element-wise.
|
||||
|
||||
Reference in New Issue
Block a user