| @@ -70,7 +70,7 @@ void PostConvFuncFp32C4(const float *c4_out_ptr, float *out_ptr, const float *bi | |||||
| #ifndef ENABLE_ARM | #ifndef ENABLE_ARM | ||||
| void WinogradTransLeft(const float *S, const float *B, float *M, size_t w, size_t h, size_t k, size_t length) { | void WinogradTransLeft(const float *S, const float *B, float *M, size_t w, size_t h, size_t k, size_t length) { | ||||
| int unitStep = 4 * length; | |||||
| const int unitStep = 4 * length; | |||||
| for (int y = 0; y < h; ++y) { | for (int y = 0; y < h; ++y) { | ||||
| float *dstY = M + y * w * unitStep; | float *dstY = M + y * w * unitStep; | ||||
| for (int x = 0; x < w; ++x) { | for (int x = 0; x < w; ++x) { | ||||
| @@ -93,7 +93,7 @@ void WinogradTransLeft(const float *S, const float *B, float *M, size_t w, size_ | |||||
| // M = S * B , M = w*h * l, S = k*h * l, B = w*k | // M = S * B , M = w*h * l, S = k*h * l, B = w*k | ||||
| void WinogradTransRight(const float *S, const float *B, float *M, size_t w, size_t h, size_t k, size_t length) { | void WinogradTransRight(const float *S, const float *B, float *M, size_t w, size_t h, size_t k, size_t length) { | ||||
| int unitStep = 4 * length; | |||||
| const int unitStep = 4 * length; | |||||
| for (int y = 0; y < h; ++y) { | for (int y = 0; y < h; ++y) { | ||||
| float *dstY = M + y * w * unitStep; | float *dstY = M + y * w * unitStep; | ||||
| const float *srcY = S + y * k * unitStep; | const float *srcY = S + y * k * unitStep; | ||||
| @@ -163,7 +163,7 @@ void DeConvWgInputPack(float *src_ptr, float *dst_ptr, int channel, int stride) | |||||
| #ifndef ENABLE_ARM | #ifndef ENABLE_ARM | ||||
| void TiledC4MatmulFp32(float *dst, const float *src, const float *weight, size_t cal_num, size_t ic4, size_t oc4) { | void TiledC4MatmulFp32(float *dst, const float *src, const float *weight, size_t cal_num, size_t ic4, size_t oc4) { | ||||
| int dx, sz, dz; | int dx, sz, dz; | ||||
| int src_depth_step = 4 * DECONV_WINOGRAD_DEFAULT_TILE; | |||||
| const int src_depth_step = 4 * DECONV_WINOGRAD_DEFAULT_TILE; | |||||
| for (dz = 0; dz < oc4; ++dz) { | for (dz = 0; dz < oc4; ++dz) { | ||||
| float *dst_z = dst + dz * cal_num; | float *dst_z = dst + dz * cal_num; | ||||
| const float *weight_dz = weight + dz * ic4 * 16; | const float *weight_dz = weight + dz * ic4 * 16; | ||||
| @@ -65,6 +65,9 @@ int DecodeBoxes(const int num_boxes, const float *input_boxes, const float *anch | |||||
| int NmsSingleClass(const int num_boxes, const float *decoded_boxes, const int max_detections, const float *scores, | int NmsSingleClass(const int num_boxes, const float *decoded_boxes, const int max_detections, const float *scores, | ||||
| int *selected, void (*PartialArgSort)(const float *, int *, int, int), | int *selected, void (*PartialArgSort)(const float *, int *, int, int), | ||||
| const DetectionPostProcessParameter *param) { | const DetectionPostProcessParameter *param) { | ||||
| if (PartialArgSort == NULL) { | |||||
| return NNACL_NULL_PTR; | |||||
| } | |||||
| uint8_t *nms_candidate = param->nms_candidate_; | uint8_t *nms_candidate = param->nms_candidate_; | ||||
| const int output_num = num_boxes < max_detections ? num_boxes : max_detections; | const int output_num = num_boxes < max_detections ? num_boxes : max_detections; | ||||
| int possible_candidate_num = num_boxes; | int possible_candidate_num = num_boxes; | ||||
| @@ -144,7 +147,11 @@ int DetectionPostProcessFast(const int num_boxes, const int num_classes_with_bg, | |||||
| for (int j = 0; j < max_classes_per_anchor; ++j) { | for (int j = 0; j < max_classes_per_anchor; ++j) { | ||||
| *((BboxCorner *)(output_boxes) + out_num) = *box; | *((BboxCorner *)(output_boxes) + out_num) = *box; | ||||
| output_scores[out_num] = input_scores[indexes[j]]; | output_scores[out_num] = input_scores[indexes[j]]; | ||||
| output_classes[out_num++] = (float)(indexes[j] % num_classes_with_bg - first_class_index); | |||||
| if (num_classes_with_bg != 0) { | |||||
| output_classes[out_num++] = (float)(indexes[j] % num_classes_with_bg - first_class_index); | |||||
| } else { | |||||
| return NNACL_ERRCODE_DIVISOR_ZERO; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| *output_num = (float)out_num; | *output_num = (float)out_num; | ||||
| @@ -38,7 +38,7 @@ int InstanceNorm(const int outer_size, const int inner_size, const float *src_da | |||||
| } | } | ||||
| mean /= (float)inner_size; | mean /= (float)inner_size; | ||||
| square_mean /= (float)inner_size; | square_mean /= (float)inner_size; | ||||
| float deno = 1 / sqrtf(square_mean - mean * mean + param->epsilon_); | |||||
| const float deno = 1 / sqrtf(square_mean - mean * mean + param->epsilon_); | |||||
| for (i = 0; i < inner_size; ++i) { | for (i = 0; i < inner_size; ++i) { | ||||
| int idx = j % param->channel_ + i * param->channel_; | int idx = j % param->channel_ + i * param->channel_; | ||||
| int scale_idx = (j / param->channel_) * param->channel_ + j % param->channel_; | int scale_idx = (j / param->channel_) * param->channel_ + j % param->channel_; | ||||
| @@ -39,7 +39,7 @@ int LayerNorm(const int outer_size, const int inner_size, const float *src_data, | |||||
| } | } | ||||
| mean /= (float)inner_size; | mean /= (float)inner_size; | ||||
| square_mean /= (float)inner_size; | square_mean /= (float)inner_size; | ||||
| float deno = 1 / sqrtf(square_mean - mean * mean + epsilon); | |||||
| const float deno = 1 / sqrtf(square_mean - mean * mean + epsilon); | |||||
| for (i = 0; i < inner_size; ++i) { | for (i = 0; i < inner_size; ++i) { | ||||
| dst[i] = (src[i] - mean) * deno; | dst[i] = (src[i] - mean) * deno; | ||||
| if (affine) { | if (affine) { | ||||
| @@ -118,7 +118,7 @@ void PReluShareChannel(float *input, float *output, PReluParameter *prelu_param_ | |||||
| cal_index = j * 32; | cal_index = j * 32; | ||||
| #else | #else | ||||
| cal_index = j * 32; | cal_index = j * 32; | ||||
| int cal_per_time = 32; | |||||
| const int cal_per_time = 32; | |||||
| #endif | #endif | ||||
| float *input_ptr = input + cal_index; | float *input_ptr = input + cal_index; | ||||
| float *output_ptr = input + cal_index; | float *output_ptr = input + cal_index; | ||||
| @@ -19,7 +19,7 @@ | |||||
| static void BinaryCrossEntropyLossKernel(const int input_size, const int reduction, const float *input_x, | static void BinaryCrossEntropyLossKernel(const int input_size, const int reduction, const float *input_x, | ||||
| const float *input_y, const float *weight, float *loss, float *tmp_loss) { | const float *input_y, const float *weight, float *loss, float *tmp_loss) { | ||||
| float epsilon = 1e-12; | |||||
| const float epsilon = 1e-12; | |||||
| if (reduction == 0) { | if (reduction == 0) { | ||||
| for (int i = 0; i < input_size; i++) { | for (int i = 0; i < input_size; i++) { | ||||
| float value = | float value = | ||||
| @@ -20,7 +20,7 @@ | |||||
| int BinaryCrossEntropyGrad(const int input_size, const int reduction, const float *input_x, const float *input_y, | int BinaryCrossEntropyGrad(const int input_size, const int reduction, const float *input_x, const float *input_y, | ||||
| const float *weight, const float *dloss, float *dx) { | const float *weight, const float *dloss, float *dx) { | ||||
| float epsilon = 1e-12; | |||||
| const float epsilon = 1e-12; | |||||
| if (reduction == 0) { | if (reduction == 0) { | ||||
| for (int i = 0; i < input_size; i++) { | for (int i = 0; i < input_size; i++) { | ||||
| float denominator = MAX(input_x[i] * (1 - input_x[i]), epsilon); | float denominator = MAX(input_x[i] * (1 - input_x[i]), epsilon); | ||||
| @@ -247,7 +247,7 @@ void ConvDw3x3Int8Row(int8_t *output, int8_t *buffer, const int8_t *input, const | |||||
| int acc_min = conv_param->conv_quant_arg_.out_act_min_[0]; | int acc_min = conv_param->conv_quant_arg_.out_act_min_[0]; | ||||
| int acc_max = conv_param->conv_quant_arg_.out_act_max_[0]; | int acc_max = conv_param->conv_quant_arg_.out_act_max_[0]; | ||||
| int ih_offset = 64 * block_input_w; | |||||
| const int ih_offset = 64 * block_input_w; | |||||
| int w = start_w; | int w = start_w; | ||||
| if (conv_param->output_channel_ > 64 || (conv_param->output_channel_ < 64 && conv_param->input_w_ > 150)) { | if (conv_param->output_channel_ > 64 || (conv_param->output_channel_ < 64 && conv_param->input_w_ > 150)) { | ||||
| for (; w <= end_w - block_output_w; w += block_output_w) { | for (; w <= end_w - block_output_w; w += block_output_w) { | ||||
| @@ -295,9 +295,9 @@ void ConvDw3x3Int8(int8_t *output_data, int8_t *buffer, const int8_t *input_data | |||||
| int start_ow = sliding->left_; | int start_ow = sliding->left_; | ||||
| int end_ow = sliding->right_; | int end_ow = sliding->right_; | ||||
| int block_output_h = 1; | |||||
| const int block_output_h = 1; | |||||
| int block_output_w = conv_param->stride_w_ == 1 ? 30 : 14; | int block_output_w = conv_param->stride_w_ == 1 ? 30 : 14; | ||||
| int block_input_h = 3; | |||||
| const int block_input_h = 3; | |||||
| int block_input_w = conv_param->stride_w_ * (block_output_w - 1) + 3; | int block_input_w = conv_param->stride_w_ * (block_output_w - 1) + 3; | ||||
| for (int b = 0; b < conv_param->output_batch_; b++) { | for (int b = 0; b < conv_param->output_batch_; b++) { | ||||
| @@ -467,9 +467,9 @@ void MaxPoolingOptInt8(const int8_t *input_ptr, int8_t *output_ptr, PoolingParam | |||||
| int out_h_index = index / output_w; | int out_h_index = index / output_w; | ||||
| int in_w_index = out_w_index * stride_w - pad_w; | int in_w_index = out_w_index * stride_w - pad_w; | ||||
| int in_h_index = out_h_index * stride_h - pad_h; | int in_h_index = out_h_index * stride_h - pad_h; | ||||
| int ky_s = 0 > (-in_h_index) ? 0 : (-in_h_index); | |||||
| const int ky_s = 0 > (-in_h_index) ? 0 : (-in_h_index); | |||||
| int ky_e = MSMIN(win_h, in_h - in_h_index); | int ky_e = MSMIN(win_h, in_h - in_h_index); | ||||
| int kx_s = 0 > (-in_w_index) ? 0 : (-in_w_index); | |||||
| const int kx_s = 0 > (-in_w_index) ? 0 : (-in_w_index); | |||||
| int kx_e = MSMIN(win_w, in_w - in_w_index); | int kx_e = MSMIN(win_w, in_w - in_w_index); | ||||
| int input_stride = (in_h_index * in_w + in_w_index) * channel + in_batch_offset; | int input_stride = (in_h_index * in_w + in_w_index) * channel + in_batch_offset; | ||||
| int out_plane_offset = out_batch_offset + index * channel; | int out_plane_offset = out_batch_offset + index * channel; | ||||
| @@ -56,7 +56,7 @@ int AudioSpectrogram::Log2Ceil(uint32_t length) { | |||||
| } | } | ||||
| int floor = 0; | int floor = 0; | ||||
| for (int i = 4; i >= 0; --i) { | for (int i = 4; i >= 0; --i) { | ||||
| int shift = (1 << i); | |||||
| const int shift = (1 << i); | |||||
| uint32_t tmp = length >> shift; | uint32_t tmp = length >> shift; | ||||
| if (tmp != 0) { | if (tmp != 0) { | ||||
| length = tmp; | length = tmp; | ||||