tinygrad / tinygrad

You like pytorch? You like micrograd? You love tinygrad! ❤️
MIT License
26.86k stars 2.98k forks source link

CLANG has different casting behavior with intermediate inf #7516

Open chenyuxyz opened 1 week ago

chenyuxyz commented 1 week ago

from https://github.com/tinygrad/tinygrad/issues/7421#issuecomment-2453046963

CLANG=1 python -c "from tinygrad import Tensor; print(Tensor([30000], dtype='half').mul(200).float().item())" returns 6000000.0 which is larger than max fp16.

cold0dev commented 1 week ago

For some reason it works fine when .numpy() is called

from tinygrad import Tensor
print(Tensor([30000], dtype='half').mul(200).float().item())
t = Tensor([30000], dtype='half').mul(200)
t.numpy()
a = t.float().item()
print(a)
6000000.0
inf