Skip to content

Commit 7cc7f57

Browse files
committed
Fix cupy subnormals
1 parent 7c6a178 commit 7cc7f57

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tests/test_funcs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ def test_hypothesis( # type: ignore[no-any-explicit,no-any-decorated]
235235
data.draw(npst.arrays(dtype=dtype, shape=(), elements=elements))
236236
)
237237
float_fill_value = float(fill_value)
238+
if library is Backend.CUPY and dtype is np.float32:
239+
# Avoid data-dependent dtype promotion when encountering subnormals
240+
# close to the max float32 value
241+
float_fill_value = float(np.clip(float_fill_value, -1e38, 1e38))
242+
238243
arrays = tuple(
239244
xp.asarray(
240245
data.draw(npst.arrays(dtype=dtype, shape=shape, elements=elements))

0 commit comments

Comments
 (0)