From e9f75a2b73485d6a10baf4956986fa42218909eb Mon Sep 17 00:00:00 2001 From: ling Date: Sat, 29 Aug 2020 09:55:27 +0800 Subject: [PATCH] [MS][LITE][Develop]optimize log info --- mindspore/lite/include/context.h | 2 +- mindspore/lite/nnacl/optimized_kernel.h | 6 +++--- .../src/runtime/kernel/arm/fp16/convolution_1x1_fp16.cc | 3 ++- .../src/runtime/kernel/arm/fp16/deconvolution_fp16.cc | 6 ++++-- .../lite/src/runtime/kernel/arm/fp32/convolution_1x1.cc | 3 ++- .../lite/src/runtime/kernel/arm/fp32/deconvolution.cc | 7 +++++-- .../src/runtime/kernel/arm/int8/convolution_1x1_int8.cc | 4 +++- .../src/runtime/kernel/arm/int8/deconvolution_int8.cc | 9 +++++++-- 8 files changed, 27 insertions(+), 13 deletions(-) diff --git a/mindspore/lite/include/context.h b/mindspore/lite/include/context.h index b7400399242..233c2441ad0 100644 --- a/mindspore/lite/include/context.h +++ b/mindspore/lite/include/context.h @@ -65,7 +65,7 @@ class MS_API Context { virtual ~Context(); public: - bool float16_priority = false; /**< allow priority select float16 kernel */ + bool float16_priority = false; /**< prior enable float16 inference */ DeviceContext device_ctx_{DT_CPU}; int thread_num_ = 2; /**< thread number config for thread pool */ std::shared_ptr allocator = nullptr; diff --git a/mindspore/lite/nnacl/optimized_kernel.h b/mindspore/lite/nnacl/optimized_kernel.h index d3df6c89e2d..26dea2b4af9 100644 --- a/mindspore/lite/nnacl/optimized_kernel.h +++ b/mindspore/lite/nnacl/optimized_kernel.h @@ -50,10 +50,10 @@ class OptimizeModule { #ifdef ENABLE_ARM64 if (hwcap & HWCAP_ASIMDDP) { - printf("Hw cap support SMID Dot Product, hwcap: 0x%x \n", hwcap); + MS_LOG(INFO) << "Hw cap support SMID Dot Product, hwcap: 0x" << hwcap; support_optimize_ops = true; } else { - printf("Hw cap NOT support SIMD Dot Product, hwcap: 0x%x\n", hwcap); + MS_LOG(INFO) << "Hw cap NOT support SIMD Dot Product, hwcap: 0x" << hwcap; } #endif #endif @@ -63,7 +63,7 @@ class OptimizeModule { #ifndef _WIN32 optimized_op_handler_ = dlopen(OPTIMIZE_SHARED_LIBRARY_PATH, RTLD_LAZY); if (optimized_op_handler_ == nullptr) { - printf("Open optimize shared library failed: %s\n", dlerror()); + MS_LOG(INFO) << "Open optimize shared library failed: " << dlerror(); } #endif } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_1x1_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_1x1_fp16.cc index 7c0e35c706c..888c2f8e1a9 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_1x1_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_1x1_fp16.cc @@ -178,7 +178,8 @@ void Convolution1x1FP16CPUKernel::Pre1x1Trans(float16_t *src_input, float16_t *s } int Convolution1x1FP16CPUKernel::RunImpl(int task_id) { - int cur_oc = MSMIN(thread_stride_, matmul_param_->col_ - task_id * thread_stride_); + int cur_stride = matmul_param_->col_ - task_id * thread_stride_; + int cur_oc = MSMIN(thread_stride_, cur_stride); if (cur_oc <= 0) { return RET_OK; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc index 817bb914970..718ce958954 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc @@ -148,8 +148,10 @@ static int DeConvFp16Run(void *cdata, int task_id) { } int DeConvolutionFp16CPUKernel::DoDeconv(int task_id) { - int oc = MSMIN(thread_stride_, UP_DIV(conv_param_->output_channel_, C8NUM) - task_id * thread_stride_); - int oc_res = MSMIN(thread_stride_ * C8NUM, conv_param_->output_channel_ - task_id * thread_stride_ * C8NUM); + int cur_stride = UP_DIV(conv_param_->output_channel_, C8NUM) - task_id * thread_stride_; + int oc = MSMIN(thread_stride_, cur_stride); + cur_stride = conv_param_->output_channel_ - task_id * thread_stride_ * C8NUM; + int oc_res = MSMIN(thread_stride_ * C8NUM, cur_stride); if (oc <= 0) { return RET_OK; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1.cc index 983cdddd1b4..66accb16846 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1.cc @@ -137,7 +137,8 @@ int Convolution1x1CPUKernel::Init() { } int Convolution1x1CPUKernel::DoConv1x1(int task_id) { - int cur_oc = MSMIN(thread_stride_, matmul_param_->col_ - task_id * thread_stride_); + int res_stride = matmul_param_->col_ - task_id * thread_stride_; + int cur_oc = MSMIN(thread_stride_, res_stride); if (cur_oc <= 0) { return RET_OK; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution.cc index 26870046df6..7cac6982ac5 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution.cc @@ -103,8 +103,11 @@ int DeConvFp32Run(void *cdata, int task_id) { } int DeConvolutionCPUKernel::DoDeconv(int task_id) { - int oc = MSMIN(thread_stride_, UP_DIV(conv_param_->output_channel_, C8NUM) - task_id * thread_stride_); - int oc_res = MSMIN(thread_stride_ * C8NUM, conv_param_->output_channel_ - task_id * thread_stride_ * C8NUM); + int res_stride = UP_DIV(conv_param_->output_channel_, C8NUM) - task_id * thread_stride_; + int oc = MSMIN(thread_stride_, res_stride); + int cur_stride = thread_stride_ * C8NUM; + res_stride = conv_param_->output_channel_ - task_id * thread_stride_ * C8NUM; + int oc_res = MSMIN(cur_stride, res_stride); if (oc <= 0 || oc_res <= 0) { return RET_OK; } diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/convolution_1x1_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/convolution_1x1_int8.cc index 128c88f3e59..110b0a5d4b8 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/convolution_1x1_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/convolution_1x1_int8.cc @@ -272,7 +272,9 @@ int Convolution1x1Int8CPUKernel::RunImpl(int task_id) { } int Convolution1x1Int8CPUKernel::RunPre(int task_id) { - int cur_hw = MSMIN(thread_stride_hw_ * C8NUM, matmul_param_->row_ - task_id * thread_stride_hw_ * C8NUM); + int cur_stride = thread_stride_hw_ * C8NUM; + int res_stride = matmul_param_->row_ - task_id * thread_stride_hw_ * C8NUM; + int cur_hw = MSMIN(cur_stride, res_stride); if (cur_hw <= 0) { return RET_OK; } diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/deconvolution_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/deconvolution_int8.cc index 8f4b06d55d2..dd6161df35f 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/deconvolution_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/deconvolution_int8.cc @@ -227,8 +227,13 @@ int DeConvInt8Run(void *cdata, int task_id) { } int DeConvInt8CPUKernel::DoDeconv(int task_id) { - int cur_oc = MSMIN(thread_stride_, UP_DIV(conv_param_->output_channel_, C8NUM) - task_id * thread_stride_); - int cur_oc_res = MSMIN(thread_stride_ * C4NUM, conv_param_->output_channel_ - task_id * thread_stride_ * C4NUM); + int cur_stride = thread_stride_; + int res_stride = UP_DIV(conv_param_->output_channel_, C8NUM) - task_id * thread_stride_; + int cur_oc = MSMIN(cur_stride, res_stride); + + cur_stride = thread_stride_ * C4NUM; + res_stride = conv_param_->output_channel_ - task_id * thread_stride_ * C4NUM; + int cur_oc_res = MSMIN(cur_stride, res_stride); if (cur_oc <= 0) { return RET_OK; }