diff --git a/mindspore/lite/nnacl/fp32_grad/batch_norm.c b/mindspore/lite/nnacl/fp32_grad/batch_norm.c index a6d2b20ed8d..a353dbc85f0 100644 --- a/mindspore/lite/nnacl/fp32_grad/batch_norm.c +++ b/mindspore/lite/nnacl/fp32_grad/batch_norm.c @@ -48,7 +48,7 @@ void backwardX(const float *in, const float *dout, const float *scale, const int meanVar(in, size, channels, eps, mean, invar); for (int i = 0; i < size; i++) { for (int f = 0; f < channels; f++) { - int ix = i*channels + f; + int ix = i * channels + f; float x_hat = (in[ix] - mean[f]) * invar[f]; float dxhat = dout[ix] * scale[f]; dxhat_sum[f] += dxhat; @@ -57,7 +57,7 @@ void backwardX(const float *in, const float *dout, const float *scale, const int } for (int i = 0; i < size; i++) { for (int f = 0; f < channels; f++) { - int ix = i*channels + f; + int ix = i * channels + f; float x_hat = (in[ix] - mean[f]) * invar[f]; float dxhat = dout[ix] * scale[f]; out[ix] = 1.f / size * invar[f] * (size * dxhat - dxhat_sum[f] - x_hat * dxhathat_sum[f]); diff --git a/mindspore/lite/nnacl/minimal_filtering_generator.h b/mindspore/lite/nnacl/minimal_filtering_generator.h index c6ce595a58d..95098d5b4dc 100644 --- a/mindspore/lite/nnacl/minimal_filtering_generator.h +++ b/mindspore/lite/nnacl/minimal_filtering_generator.h @@ -43,7 +43,7 @@ void MatrixTranspose(float *matrix, float *trans_matrix, int row, int col); void MatrixMultiply(const float *matrix_a, const float *matrix_b, float *matrix_c, int m, int k, int n); int CookToomFilter(float *matrix_a, float *matrix_at, float *matrix_b, float *matrix_bt, float *matrix_g, - float *matrix_gt, float coefficient, int out_unit, int filter_size); + float *matrix_gt, float coefficient, int out_unit, int filter_size); #ifdef ENABLE_ARM void MatrixMultiplyVec(const float32x4_t *matrix_a, const float32x4_t *matrix_b, float32x4_t *matrix_c, diff --git a/mindspore/lite/nnacl/optimized_kernel.h b/mindspore/lite/nnacl/optimized_kernel.h index 162aa0433c1..7b3d7332e01 100644 --- a/mindspore/lite/nnacl/optimized_kernel.h +++ b/mindspore/lite/nnacl/optimized_kernel.h @@ -37,7 +37,6 @@ class OptimizeModule { #ifdef ENABLE_ARM64 int hwcap_type = 16; uint32_t hwcap = getHwCap(hwcap_type); - if (hwcap & HWCAP_ASIMDDP) { MS_LOG(INFO) << "Hw cap support SMID Dot Product, hwcap: 0x" << hwcap; support_optimize_ops = true; @@ -72,7 +71,6 @@ class Float16Module { #ifdef ENABLE_ARM64 int hwcap_type = 16; uint32_t hwcap = getHwCap(hwcap_type); - if (hwcap & HWCAP_FPHP) { MS_LOG(INFO) << "Hw cap support FP16, hwcap: 0x" << hwcap; support_fp16 = true; diff --git a/mindspore/lite/tools/time_profiler/time_profiler.cc b/mindspore/lite/tools/time_profiler/time_profiler.cc index 1fcf0800c50..555d0af4c21 100644 --- a/mindspore/lite/tools/time_profiler/time_profiler.cc +++ b/mindspore/lite/tools/time_profiler/time_profiler.cc @@ -80,6 +80,7 @@ int TimeProfiler::ReadInputFile() { } auto input_data = inTensor->MutableData(); memcpy(input_data, bin_buf, tensor_data_size); + delete bin_buf; return RET_OK; } @@ -104,15 +105,10 @@ int TimeProfiler::LoadInput() { } int TimeProfiler::InitSession() { - size_t size = 0; - char *graph_buf = ReadFile(_flags->model_path_.c_str(), &size); - if (graph_buf == nullptr) { - MS_LOG(ERROR) << "Load graph failed, path " << _flags->model_path_; - std::cerr << "Load graph failed, path " << _flags->model_path_ << std::endl; + ctx = new (std::nothrow) lite::Context; + if (ctx == nullptr) { return RET_ERROR; } - - auto ctx = new lite::Context; ctx->cpu_bind_mode_ = static_cast(_flags->cpu_bind_mode_); ctx->device_type_ = lite::DT_CPU; ctx->thread_num_ = _flags->num_threads_; @@ -239,7 +235,7 @@ int TimeProfiler::Init() { } int TimeProfiler::PrintResult(const std::vector &title, - const std::map> &result) { + const std::map> &result) { std::vector columnLenMax(5); std::vector> rows; diff --git a/mindspore/lite/tools/time_profiler/time_profiler.h b/mindspore/lite/tools/time_profiler/time_profiler.h index c43429476cf..8b1121b03b7 100644 --- a/mindspore/lite/tools/time_profiler/time_profiler.h +++ b/mindspore/lite/tools/time_profiler/time_profiler.h @@ -57,7 +57,11 @@ class MS_API TimeProfilerFlags : public virtual FlagParser { class MS_API TimeProfiler { public: explicit TimeProfiler(TimeProfilerFlags *flags) : _flags(flags) {} - ~TimeProfiler() = default; + ~TimeProfiler() { + if (ctx != nullptr) { + delete ctx; + } + } int Init(); int RunTimeProfiler(); @@ -72,6 +76,7 @@ class MS_API TimeProfiler { int PrintResult(const std::vector &title, const std::map> &result); private: + Context *ctx = nullptr; TimeProfilerFlags *_flags; std::vector ms_inputs_; session::LiteSession *session_;