Add casts to std::min/std::max when comparing mis-matched types

This commit is contained in:
Jenny Plunkett 2020-12-08 12:59:29 -06:00
parent 0cc38aaa40
commit 36e125eaa2
No known key found for this signature in database
GPG Key ID: 03BA901497DEEB3E
2 changed files with 6 additions and 6 deletions

View File

@ -297,10 +297,10 @@ inline void gen_lut(double (*func)(double), double min, double max,
TfLiteRound(func(min + i * step + half_step) * 32768.0);
double midpoint_err = midpoint_interp_val - midpoint_val;
double bias = TfLiteRound(midpoint_err / 2.0);
table[i] = std::min(std::max(sample_val - bias, -32768.0), 32767.0);
table[i] = std::min<double>(std::max<double>(sample_val - bias, -32768.0), 32767.0);
}
table[num - 1] =
std::min(std::max(TfLiteRound(func(max) * 32768.0), -32768.0), 32767.0);
std::min<double>(std::max<double>(TfLiteRound(func(max) * 32768.0), -32768.0), 32767.0);
}
// generate INT16 LUT for function(), e.g., table exp(x) and 1/(1+x) used in
@ -325,10 +325,10 @@ inline void gen_lut(float (*func)(float), float min, float max, int16_t* table,
TfLiteRound(func(min + i * step + half_step) * 32768.0f);
float midpoint_err = midpoint_interp_val - midpoint_val;
float bias = TfLiteRound(midpoint_err / 2.0f);
table[i] = std::min(std::max(sample_val - bias, -32768.0f), 32767.0f);
table[i] = std::min<float>(std::max<float>(sample_val - bias, -32768.0f), 32767.0f);
}
table[num - 1] = std::min(
std::max(TfLiteRound(func(max) * 32768.0f), -32768.0f), 32767.0f);
table[num - 1] = std::min<float>(
std::max<float>(TfLiteRound(func(max) * 32768.0f), -32768.0f), 32767.0f);
}
// int16_t func table lookup, e.g., lookup exp() and 1/(1+x) used in softmax

View File

@ -289,7 +289,7 @@ void PreprocessSoftmaxScaling(double beta, double input_scale,
input_beta_real_multiplier = (1ll << 31) - 1.0;
}
#else // TFLITE_EMULATE_FLOAT
const double input_beta_real_multiplier = std::min(
const double input_beta_real_multiplier = std::min<double>(
beta * input_scale * (1 << (31 - input_integer_bits)), (1ll << 31) - 1.0);
#endif // TFLITE_EMULATE_FLOAT