Skip to content

Commit 09edea4

Browse files
authored
Fix -Wimplicit-const-int-float-conversion error.
Differential Revision: D87882617 Pull Request resolved: pytorch#15982
1 parent a042763 commit 09edea4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

backends/cadence/vision/kernels/kernels.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <algorithm>
1212
#include <cstring>
1313
#include <limits>
14-
#include <numeric>
1514

1615
namespace impl {
1716
namespace vision {
@@ -25,10 +24,10 @@ void* allocate_temp_memory(KernelRuntimeContext& ctx, size_t size) {
2524
// Quantize a fp32 value to an int8_t/uint8_t value
2625
template <typename T>
2726
T quantize(const float x, float scale, int32_t zero_point) {
28-
constexpr float min_val = std::numeric_limits<T>::min();
29-
constexpr float max_val = std::numeric_limits<T>::max();
27+
constexpr float kMinValue = static_cast<float>(std::numeric_limits<T>::min());
28+
constexpr float kMaxValue = static_cast<float>(std::numeric_limits<T>::max());
3029
float tmp = roundf(x * scale + zero_point);
31-
return std::max(std::min(tmp, max_val), min_val);
30+
return std::max(std::min(tmp, kMaxValue), kMinValue);
3231
}
3332

3433
// Quantize an fp32 array to an int8_t/uint8_t array

0 commit comments

Comments
 (0)