From e50662798f46439151737dcde8894744ec0dada0 Mon Sep 17 00:00:00 2001 From: chenjiaoAngel Date: Thu, 7 May 2020 21:01:27 +0800 Subject: [PATCH] fix format. test=develop --- lite/backends/arm/math/gemm_prepacked_int8.cc | 75 ++++++++++++++++--- lite/backends/arm/math/gemv_arm_int8.cc | 18 +++-- lite/tests/math/conv_compute_test.cc | 10 +-- lite/tests/math/conv_int8_compute_test.cc | 10 ++- lite/tests/math/gemm_int8_compute_test.cc | 4 +- lite/tests/math/gemv_int8_compute_test.cc | 6 +- lite/tests/math/sgemv_compute_test.cc | 2 +- lite/tests/utils/naive_math_impl.h | 2 +- 8 files changed, 94 insertions(+), 33 deletions(-) diff --git a/lite/backends/arm/math/gemm_prepacked_int8.cc b/lite/backends/arm/math/gemm_prepacked_int8.cc index 5800ab2227..f45ad27415 100644 --- a/lite/backends/arm/math/gemm_prepacked_int8.cc +++ b/lite/backends/arm/math/gemm_prepacked_int8.cc @@ -4222,15 +4222,48 @@ void gemm_prepack_int8(const int8_t* A_packed, } #if defined(__aarch64__) && defined(WITH_ARM_DOTPROD) if (ctx->has_dot()) { - gemm_prepack_sdot_int8( - A_packed, B, bias, C, M, N, K, is_bias, flag_act, is_transB, scale, alpha, ctx); + gemm_prepack_sdot_int8(A_packed, + B, + bias, + C, + M, + N, + K, + is_bias, + flag_act, + is_transB, + scale, + alpha, + ctx); } else { - gemm_prepack_oth_int8( - A_packed, B, bias, C, M, N, K, is_bias, flag_act, is_transB, scale, alpha, ctx); + gemm_prepack_oth_int8(A_packed, + B, + bias, + C, + M, + N, + K, + is_bias, + flag_act, + is_transB, + scale, + alpha, + ctx); } #else - gemm_prepack_oth_int8( - A_packed, B, bias, C, M, N, K, is_bias, flag_act, is_transB, scale, alpha, ctx); + gemm_prepack_oth_int8(A_packed, + B, + bias, + C, + M, + N, + K, + is_bias, + flag_act, + is_transB, + scale, + alpha, + ctx); #endif } @@ -4271,11 +4304,33 @@ void gemm_prepack_int8(const int8_t* A_packed, } #if defined(__aarch64__) && defined(WITH_ARM_DOTPROD) if (ctx->has_dot()) { - gemm_prepack_sdot_int8( - A_packed, B, bias, C, M, N, K, is_bias, flag_act, is_transB, scale, alpha, ctx); + gemm_prepack_sdot_int8(A_packed, + B, + bias, + C, + M, + N, + K, + is_bias, + flag_act, + is_transB, + scale, + alpha, + ctx); } else { - gemm_prepack_oth_int8( - A_packed, B, bias, C, M, N, K, is_bias, flag_act, is_transB, scale, alpha, ctx); + gemm_prepack_oth_int8(A_packed, + B, + bias, + C, + M, + N, + K, + is_bias, + flag_act, + is_transB, + scale, + alpha, + ctx); } #else gemm_prepack_oth_int8( diff --git a/lite/backends/arm/math/gemv_arm_int8.cc b/lite/backends/arm/math/gemv_arm_int8.cc index ea271d08bd..86f7f47d8d 100644 --- a/lite/backends/arm/math/gemv_arm_int8.cc +++ b/lite/backends/arm/math/gemv_arm_int8.cc @@ -311,7 +311,8 @@ bool gemv_int8_oth(const int8_t* A, ptr_out[7] += ptr_in[i] * ptr_w7[i]; } - write_gemv_out(ptr_out, out_ptr, scale_ptr, bias_ptr, 8, flag_act, act, six, alpha); + write_gemv_out( + ptr_out, out_ptr, scale_ptr, bias_ptr, 8, flag_act, act, six, alpha); } //! deal with remains @@ -355,7 +356,8 @@ bool gemv_int8_oth(const int8_t* A, for (int i = 0; i < tail; ++i) { ptr_out[0] += ptr_in[i] * ptr_w0[i]; } - write_gemv_out(ptr_out, out_ptr, scale_ptr, bias_ptr, 1, flag_act, act, six, alpha); + write_gemv_out( + ptr_out, out_ptr, scale_ptr, bias_ptr, 1, flag_act, act, six, alpha); } #else // __aarch64__ int out_cnt = M >> 2; @@ -449,7 +451,8 @@ bool gemv_int8_oth(const int8_t* A, ptr_out[2] += ptr_in[i] * ptr_w2[i]; ptr_out[3] += ptr_in[i] * ptr_w3[i]; } - write_gemv_out(ptr_out, out_ptr, scale_ptr, bias_ptr, 4, flag_act, act, six, alpha); + write_gemv_out( + ptr_out, out_ptr, scale_ptr, bias_ptr, 4, flag_act, act, six, alpha); } //! deal with remains #pragma omp parallel for @@ -490,7 +493,8 @@ bool gemv_int8_oth(const int8_t* A, for (int i = 0; i < tail; ++i) { ptr_out[0] += ptr_in[i] * ptr_w0[i]; } - write_gemv_out(ptr_out, out_ptr, scale_ptr, bias_ptr, 1, flag_act, act, six, alpha); + write_gemv_out( + ptr_out, out_ptr, scale_ptr, bias_ptr, 1, flag_act, act, six, alpha); } #endif // __aarch64__ return true; @@ -648,7 +652,8 @@ bool gemv_int8_sdot(const int8_t* A, ptr_out[6] += ptr_in[i] * ptr_w6[i]; ptr_out[7] += ptr_in[i] * ptr_w7[i]; } - write_gemv_out(ptr_out, out_ptr, scale_ptr, bias_ptr, 8, flag_act, act, six, alpha); + write_gemv_out( + ptr_out, out_ptr, scale_ptr, bias_ptr, 8, flag_act, act, six, alpha); } //! deal with remains #pragma omp parallel for @@ -688,7 +693,8 @@ bool gemv_int8_sdot(const int8_t* A, for (int i = 0; i < tail; ++i) { ptr_out[0] += ptr_in[i] * ptr_w0[i]; } - write_gemv_out(ptr_out, out_ptr, scale_ptr, bias_ptr, 1, flag_act, act, six, alpha); + write_gemv_out( + ptr_out, out_ptr, scale_ptr, bias_ptr, 1, flag_act, act, six, alpha); } return true; } diff --git a/lite/tests/math/conv_compute_test.cc b/lite/tests/math/conv_compute_test.cc index 18dbf93807..e36a201149 100644 --- a/lite/tests/math/conv_compute_test.cc +++ b/lite/tests/math/conv_compute_test.cc @@ -221,11 +221,11 @@ void test_conv_fp32(const std::vector& input_dims, flag_act, six, leakey_relu_scale); - if (flag_act == 2) { // relu6 - for (int i = 0; i < dim_out.production(); i++) { - dout_basic[i] = dout_basic[i] > six ? six : dout_basic[i]; - } - } + if (flag_act == 2) { // relu6 + for (int i = 0; i < dim_out.production(); i++) { + dout_basic[i] = dout_basic[i] > six ? six : dout_basic[i]; + } + } } /// warm up for (int i = 0; i < FLAGS_warmup; ++i) { diff --git a/lite/tests/math/conv_int8_compute_test.cc b/lite/tests/math/conv_int8_compute_test.cc index 2cad0237eb..e0c878b56d 100644 --- a/lite/tests/math/conv_int8_compute_test.cc +++ b/lite/tests/math/conv_int8_compute_test.cc @@ -321,10 +321,12 @@ void test_conv_int8(const std::vector& input_dims, 1, 1, dim_out.production()); - if (flag_act == 2) { // relu6 + if (flag_act == 2) { // relu6 for (int i = 0; i < dim_out.production(); i++) { - dout_basic_int8[i] = dout_basic_int8[i] > six ? six : dout_basic_int8[i]; - dout_basic_fp32[i] = dout_basic_fp32[i] > six ? six : dout_basic_fp32[i]; + dout_basic_int8[i] = + dout_basic_int8[i] > six ? six : dout_basic_int8[i]; + dout_basic_fp32[i] = + dout_basic_fp32[i] > six ? six : dout_basic_fp32[i]; } } } @@ -526,7 +528,7 @@ TEST(TestConv5x5DWInt8, test_conv5x5_depthwise) { for (auto& stride : {1, 2}) { for (auto& pad : {0, 1, 2, 3, 4}) { for (auto& flag_bias : {false, true}) { - for (auto& flag_act: {0, 1}) { + for (auto& flag_act : {0, 1}) { for (auto& c : {1, 5, 15, 33}) { std::vector dims; DDim weights_dim({c, 1, 5, 5}); diff --git a/lite/tests/math/gemm_int8_compute_test.cc b/lite/tests/math/gemm_int8_compute_test.cc index 95edee7427..5c5a19a95c 100644 --- a/lite/tests/math/gemm_int8_compute_test.cc +++ b/lite/tests/math/gemm_int8_compute_test.cc @@ -95,8 +95,8 @@ bool test_gemm_int8(bool tra, std::vector scale_merge_int8(static_cast(m)); ActivationParam act_param; act_param.has_active = has_relu; - if (has_relu){ - act_param.active_type = (paddle::lite_api::ActivationType)1; + if (has_relu) { + act_param.active_type = (paddle::lite_api::ActivationType)1; } for (int j = 0; j < m; ++j) { scale_merge_fp32[j] = scale_a[j] * scale_b[0]; diff --git a/lite/tests/math/gemv_int8_compute_test.cc b/lite/tests/math/gemv_int8_compute_test.cc index 9e29617bb4..9a416705a9 100644 --- a/lite/tests/math/gemv_int8_compute_test.cc +++ b/lite/tests/math/gemv_int8_compute_test.cc @@ -23,7 +23,6 @@ #include "lite/core/profile/timer.h" #include "lite/core/tensor.h" #include "lite/tests/utils/tensor_utils.h" -#include "lite/backends/arm/math/saturate.h" typedef paddle::lite::Tensor Tensor; using paddle::lite::profile::Timer; @@ -99,8 +98,7 @@ bool test_gemv_int8(bool tra, } LOG(INFO) << "gemv_int8 M: " << m << ", N: " << n - << ", transA: " << (tra ? "true" : "false") - << ", act: " << flag_act + << ", transA: " << (tra ? "true" : "false") << ", act: " << flag_act << ", bias: " << (has_bias ? "true" : "false"); #ifdef LITE_WITH_ARM auto da = ta.mutable_data(); @@ -155,7 +153,7 @@ bool test_gemv_int8(bool tra, 1, 1, tc_basic_fp32.numel()); - if (flag_act == 2) { // relu6 + if (flag_act == 2) { // relu6 for (int i = 0; i < tc_basic_int8.numel(); i++) { dc_basic_fp32[i] = dc_basic_fp32[i] > six ? six : dc_basic_fp32[i]; dc_basic_int8[i] = dc_basic_int8[i] > six ? six : dc_basic_int8[i]; diff --git a/lite/tests/math/sgemv_compute_test.cc b/lite/tests/math/sgemv_compute_test.cc index 88277c0676..bf28e2b541 100644 --- a/lite/tests/math/sgemv_compute_test.cc +++ b/lite/tests/math/sgemv_compute_test.cc @@ -108,7 +108,7 @@ bool test_sgemv(bool tra, flag_act, six, alpha); - if (flag_act == 2) { // relu6 + if (flag_act == 2) { // relu6 for (int i = 0; i < tc_basic.numel(); i++) { dc_basic[i] = dc_basic[i] > six ? six : dc_basic[i]; } diff --git a/lite/tests/utils/naive_math_impl.h b/lite/tests/utils/naive_math_impl.h index 8f8151a57d..880db18517 100644 --- a/lite/tests/utils/naive_math_impl.h +++ b/lite/tests/utils/naive_math_impl.h @@ -301,7 +301,7 @@ static void conv_basic(const Dtype1* din, dst_data_ref[out_idx] = dst_data_ref[out_idx] > (Dtype2)0 ? dst_data_ref[out_idx] : (Dtype2)0; - //dst_data_ref[out_idx] = dst_data_ref[out_idx] < (Dtype2)six + // dst_data_ref[out_idx] = dst_data_ref[out_idx] < (Dtype2)six // ? dst_data_ref[out_idx] // : (Dtype2)six; } else if (act_type == 4) { -- GitLab