Skip to content

Commit

Permalink
avoid division 0 in ra as well
Browse files Browse the repository at this point in the history
  • Loading branch information
kshpv committed Nov 13, 2024
1 parent 49a822c commit eef02ef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nncf/quantization/fake_quantize.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def tune_range(
fval = -left_border * s
qval = fns.round(fval)

ra = fns.where(qval < level_high, qval / (qval - level_high) * right_border, left_border)
tensor_dtype = fns.finfo(left_border)
rb_then_result = (qval - level_high) / (qval + tensor_dtype.eps) * left_border
rb = fns.where(qval > 0.0, rb_then_result, right_border)

ra = fns.where(qval < level_high, qval / (qval - level_high + tensor_dtype.eps) * right_border, left_border)
rb = fns.where(qval > 0.0, (qval - level_high) / (qval + tensor_dtype.eps) * left_border, right_border)

range_a = right_border - ra
range_b = rb - left_border
Expand Down

0 comments on commit eef02ef

Please sign in to comment.