mirror of https://github.com/commaai/tinygrad.git
test case to show clang and python doing math in double (#3628)
This commit is contained in:
parent
568353fa84
commit
bc2a13a5f7
|
@ -530,5 +530,26 @@ class TestAutoCastType(unittest.TestCase):
|
|||
assert (Tensor([1, 2], dtype=dtypes.float16) / 2).dtype == dtypes.float16
|
||||
assert (Tensor([1, 2], dtype=dtypes.float16) / 2.0).dtype == dtypes.float16
|
||||
|
||||
class TestImplicitFunctionTypeChange(unittest.TestCase):
|
||||
def test_functions(self):
|
||||
result = []
|
||||
for func in [
|
||||
lambda t: t.exp(),
|
||||
lambda t: t.exp2(),
|
||||
lambda t: t.log(),
|
||||
lambda t: t.log2(),
|
||||
lambda t: t.sqrt(),
|
||||
lambda t: t.sin(),
|
||||
]:
|
||||
t = func(Tensor([4.0, 3.0])).max() == func(Tensor([4.0, 3.0]))
|
||||
result.append(t.numpy().sum())
|
||||
|
||||
if Device.DEFAULT not in ["PYTHON", "CLANG"]:
|
||||
assert all(result)
|
||||
else:
|
||||
# CLANG and PYTHON function default returns in double, and comparison to float can fail
|
||||
# TODO: fix this
|
||||
assert not all(result)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue