From 3ba218ef2549923b245902a7ec2d5204734b827e Mon Sep 17 00:00:00 2001 From: sunsuodong Date: Fri, 6 Nov 2020 17:56:09 +0800 Subject: [PATCH] fix code --- mindspore/lite/nnacl/minimal_filtering_generator.c | 3 +++ .../arm/fp32_grad/sparse_softmax_cross_entropy_with_logits.cc | 2 +- mindspore/lite/src/runtime/thread_pool.c | 4 ++++ mindspore/lite/tools/benchmark/benchmark.cc | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mindspore/lite/nnacl/minimal_filtering_generator.c b/mindspore/lite/nnacl/minimal_filtering_generator.c index d9a4b3094c..bac28b4aed 100644 --- a/mindspore/lite/nnacl/minimal_filtering_generator.c +++ b/mindspore/lite/nnacl/minimal_filtering_generator.c @@ -257,6 +257,9 @@ void MatrixMultiplyVec(const float32x4_t *matrix_a, const float32x4_t *matrix_b, int WinogradWeightTransform(const float *weight_data, float *winograd_data, float *matrix_g, const float *matrix_gt, int oc_block, int input_unit, int kernel_unit, int channel, int batch, bool pack) { + if (oc_block == 0) { + return NNACL_PARAM_INVALID; + } // original weight format : ohwi int oc_block_num = UP_DIV(batch, oc_block); int block_stride = channel * oc_block; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32_grad/sparse_softmax_cross_entropy_with_logits.cc b/mindspore/lite/src/runtime/kernel/arm/fp32_grad/sparse_softmax_cross_entropy_with_logits.cc index 4e29045ef2..01135de869 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32_grad/sparse_softmax_cross_entropy_with_logits.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32_grad/sparse_softmax_cross_entropy_with_logits.cc @@ -101,7 +101,7 @@ int SparseSoftmaxCrossEntropyWithLogitsCPUKernel::Execute(int task_id) { Softmax(ins, losses_, sum_data_, &sm_params_); if (is_train()) { GradPostExecute(labels, losses_, grads, out); - } else if (out != nullptr) { + } else { ForwardPostExecute(labels, losses_, out); } return RET_OK; diff --git a/mindspore/lite/src/runtime/thread_pool.c b/mindspore/lite/src/runtime/thread_pool.c index 4bb87cec53..dbed7bcb59 100644 --- a/mindspore/lite/src/runtime/thread_pool.c +++ b/mindspore/lite/src/runtime/thread_pool.c @@ -835,6 +835,10 @@ ThreadPool *CreateThreadPool(int thread_num, int mode) { } #endif ThreadPool *thread_pool = (struct ThreadPool *)(malloc(sizeof(ThreadPool))); + if (thread_pool == NULL) { + LOG_ERROR("Malloc ThreadPool failed"); + return NULL; + } thread_pool->thread_num = thread_num > MAX_THREAD_NUM ? MAX_THREAD_NUM : thread_num; thread_pool->is_alive = ATOMIC_VAR_INIT(true); thread_pool->mode = mode; diff --git a/mindspore/lite/tools/benchmark/benchmark.cc b/mindspore/lite/tools/benchmark/benchmark.cc index 0d7f10d634..3d3bc9ab69 100644 --- a/mindspore/lite/tools/benchmark/benchmark.cc +++ b/mindspore/lite/tools/benchmark/benchmark.cc @@ -275,7 +275,7 @@ int Benchmark::CompareStringData(const std::string &name, tensor::MSTensor *tens std::cout << " " << output_strings[i] << std::endl; } if (calib_strings[i] != output_strings[i]) { - MS_LOG(ERROR) << ""; + MS_LOG(ERROR) << "Compare failed, index: " << i; return RET_ERROR; } }