Skip to content

Commit

Permalink
add test for inconsistent behavior in float to int casting (tinygrad#…
Browse files Browse the repository at this point in the history
…7870)

* found teeny bug

* no healthcheck

* change function name
  • Loading branch information
geohotstan authored Nov 24, 2024
1 parent 6b8a657 commit ad9df26
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/test_dtype_alu.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,12 @@ def test_float_cast(self, a, dtype): universal_test_cast(a, dtypes.float32, dtyp
@given(ht.int32, strat.sampled_from(dtypes_float+dtypes_int+dtypes_bool))
def test_int32_cast(self, a, dtype): universal_test_cast(a, dtypes.int32, dtype)

@unittest.expectedFailure
def test_unsafe_cast_float_to_int_failure(self):
val = float(dtypes.max(dtypes.int32) - 1)
t1 = Tensor([val], dtype=dtypes.float32).cast(dtypes.int32)
t2 = Tensor(val, dtype=dtypes.float32).cast(dtypes.int32)
np.testing.assert_equal(t1.item(), t2.item())

if __name__ == '__main__':
unittest.main()

0 comments on commit ad9df26

Please sign in to comment.