Skip to content

Commit

Permalink
Fix flaky test apache#19197 by avoiding case that 0.45 mapped to 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Heafield committed Sep 21, 2020
1 parent a7b8606 commit 3aff21a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/python/unittest/test_contrib_intgemm.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def test_contrib_intgemm_prepare_data():
scaled = m * 127.0 / max_quant
# Rounding 0.5 can go up or down. Move values away from 0.5.
too_close = mx.nd.abs(mx.nd.round(scaled) - scaled) > 0.45
m += max_quant / 127.0 * 0.05 * too_close
# Add 0.2 in scaled space so (0.45, 0.55) maps to (0.65, 0.75) which will round consistently.
m += max_quant / 127.0 * 0.2 * too_close

# Reference: scale and round
ref = mx.nd.round(m * 127.0 / max_quant)
Expand Down

0 comments on commit 3aff21a

Please sign in to comment.