File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 55#include " caffe/layers/pooling_layer.hpp"
66#include " caffe/util/math_functions.hpp"
77
8+ #define SATURATE_MAX 4095
9+ #define SATURATE_MIN -4096
10+
811namespace caffe {
912
1013template <typename Dtype>
@@ -86,6 +89,10 @@ __global__ void AvePoolForward(const int nthreads,
8689 if (output_shift_instead_division != Dtype (0 )) {
8790 top_data[index] = aveval / output_shift_instead_division;
8891 top_data[index] = rint (top_data[index]);
92+ if (top_data[index] > SATURATE_MAX)
93+ top_data[index] = SATURATE_MAX;
94+ if (top_data[index] < SATURATE_MIN)
95+ top_data[index] = SATURATE_MIN;
8996 }
9097 else {
9198 top_data[index] = aveval / pool_size;
@@ -138,6 +145,10 @@ __global__ void AvePoolForward_TF(const int nthreads,
138145 else
139146 top_data[index] = aveval / output_shift_instead_division * full_pool_size / pool_size;
140147 top_data[index] = rint (top_data[index]);
148+ if (top_data[index] > SATURATE_MAX)
149+ top_data[index] = SATURATE_MAX;
150+ if (top_data[index] < SATURATE_MIN)
151+ top_data[index] = SATURATE_MIN;
141152 }
142153 else {
143154 top_data[index] = aveval / pool_size;
You can’t perform that action at this time.
0 commit comments