Skip to content

Commit 9065899

Browse files
LocalResponseNormalization: We're spending about half of the time in this function converting to and from double. Do the computation in the float domain, I don't think there is any risk of numerical instability here.
PiperOrigin-RevId: 320588654 Change-Id: Ia641f6359b5966aa669de037d355292a25c08bed
1 parent 633c41f commit 9065899

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tensorflow/lite/kernels/internal/optimized/optimized_ops.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3815,6 +3815,7 @@ inline void LocalResponseNormalization(
38153815
const int double_range = op_params.range * 2;
38163816
Eigen::VectorXf padded_square(data_in.rows() + double_range);
38173817
padded_square.setZero();
3818+
const float bias = op_params.bias;
38183819
for (int r = 0; r < data_in.cols(); ++r) {
38193820
// Do local response normalization for data_in(:, r)
38203821
// first, compute the square and store them in buffer for repeated use
@@ -3827,7 +3828,7 @@ inline void LocalResponseNormalization(
38273828
}
38283829
for (int i = 0; i < data_in.rows(); ++i) {
38293830
accumulated_scale += padded_square(i + double_range);
3830-
data_out(i, r) = op_params.bias + accumulated_scale;
3831+
data_out(i, r) = bias + accumulated_scale;
38313832
accumulated_scale -= padded_square(i);
38323833
}
38333834
}

0 commit comments

Comments
 (0)