fix view add 0 (#10840)

This commit is contained in:
George Hotz
2025-06-16 16:46:12 -07:00
committed by GitHub
parent b5ce227850
commit a493eb396c
4 changed files with 19 additions and 9 deletions

View File

@@ -443,5 +443,13 @@ class TestToDtype(unittest.TestCase):
self.assertIsInstance(res, DType)
self.assertEqual(res, dtypes.int32)
@unittest.skipUnless(is_dtype_supported(dtypes.bfloat16), f"no bfloat16 on {Device.DEFAULT}")
class TestOpsBFloat16(unittest.TestCase):
def test_cast(self):
# TODO: helper_test_op breaks in unrelated part
# TODO: wrong output with GPU=1 / PYTHON=1 on mac
data = [60000.0, 70000.0, 80000.0]
np.testing.assert_allclose(Tensor(data).cast("bfloat16").numpy(), torch.tensor(data).type(torch.bfloat16).float().numpy())
if __name__ == '__main__':
unittest.main()