Skip to content

Commit ee69a2a

Browse files
committed
allow for quite small scale (shift<-31) in conv, use 0 for shift/mul in this case
1 parent 26f3667 commit ee69a2a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/caffe/util/math_functions.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,12 @@ int tfl_QuantizeMultiplier(double scale, int *shift) {
600600
double q_mul = std::frexp(scale, shift);
601601
long long quantized_multiplier = (long long) std::round(q_mul * (1ll<<31));
602602
CHECK_LT(quantized_multiplier, 1ll<<31);
603-
CHECK_GE(*shift, -31);
603+
//CHECK_GE(*shift, -31);
604+
if(*shift< -31)
605+
{
606+
*shift = 0;
607+
return int(0);
608+
}
604609
return (int) quantized_multiplier;
605610
}
606611
int tfl_MultiplyByQuantizedMultiplier(int x, int q_mul, int shift) {

0 commit comments

Comments
 (0)