impprove loop fusion
@@ -48,21 +48,16 @@ void func_QTZ_binary_channel_wise_mean_scaling(
T_UINT in_channel)
{
unsigned num_elems_in_channel = in_height * in_width * in_depth;
- T_FLOAT sum[in_channel];
- T_FLOAT mean[in_channel];
-
- for (unsigned i = 0; i < in_channel; i++) {
- sum[i] = 0;
- }
+ T_FLOAT sum;
for(unsigned i = 0; i < in_channel; i++) {
+ sum = 0;
for(unsigned j = 0; j < num_elems_in_channel; j++) {
- sum[i] += std::abs(input[i * num_elems_in_channel + j]);
- }
- mean[i] = sum[i] / num_elems_in_channel;
+ sum += std::abs(input[i * num_elems_in_channel + j]);
for(unsigned j = 0; j < num_elems_in_channel; j++) {
unsigned in_index = i * num_elems_in_channel + j;
- output[in_index] = (input[in_index] >= 0) ? mean[i] : -1 * mean[i];
+ output[in_index] = (input[in_index] >= 0) ? sum / num_elems_in_channel : -1 * sum / num_elems_in_channel;
+ }
}
}
}
