From 3333c2cdbdd4ad65723e84658f548a51acdba2fc Mon Sep 17 00:00:00 2001 From: yangruoqi713 Date: Mon, 2 Aug 2021 11:10:48 +0800 Subject: [PATCH] [MSLITE][DEVELOP] remove malloc for model GetInputs API, clean code check --- mindspore/lite/src/cxx_api/model/model_impl.cc | 1 - mindspore/lite/src/runtime/kernel/arm/base/stack_base.cc | 6 +++--- .../lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/mindspore/lite/src/cxx_api/model/model_impl.cc b/mindspore/lite/src/cxx_api/model/model_impl.cc index f22dd3a2f5e..ce81c2df17f 100644 --- a/mindspore/lite/src/cxx_api/model/model_impl.cc +++ b/mindspore/lite/src/cxx_api/model/model_impl.cc @@ -260,7 +260,6 @@ std::vector ModelImpl::GetInputs() { } res.resize(inputs.size()); for (size_t i = 0; i < inputs.size(); i++) { - inputs[i]->MutableData(); // prepare data auto impl = std::shared_ptr(new (std::nothrow) MSTensor::Impl(inputs[i])); if (impl == nullptr || impl->lite_tensor() == nullptr) { MS_LOG(ERROR) << "Create tensor failed."; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/stack_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/stack_base.cc index 91aa761aab1..c9d6c6ae48c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/stack_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/stack_base.cc @@ -78,7 +78,7 @@ int StackBaseCPUKernel::Init() { } int StackBaseCPUKernel::Execute(int task_id) { - auto output_data = reinterpret_cast(out_tensors_.at(0)->data_c()); + auto output_data = reinterpret_cast(out_tensors_.at(0)->data_c()); if (output_data == nullptr) { return RET_NULL_PTR; } @@ -86,7 +86,7 @@ int StackBaseCPUKernel::Execute(int task_id) { auto start = task_id * step; auto end = MSMIN(start + step, outer_size_); auto input_num = in_tensors_.size(); - auto output = output_data + input_num * start * copy_size_; + auto output = reinterpret_cast(output_data) + input_num * start * copy_size_; Stack(all_inputs_, reinterpret_cast(output), input_num, copy_size_, start, end); return RET_OK; } @@ -106,7 +106,7 @@ int StackBaseCPUKernel::Run() { return RET_ERROR; } for (size_t j = 0; j < inputs_num; ++j) { - auto input_data = reinterpret_cast(in_tensors_.at(j)->data_c()); + auto input_data = reinterpret_cast(in_tensors_.at(j)->data_c()); if (input_data == nullptr) { return RET_NULL_PTR; } 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 87093a8605d..2294209a087 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc @@ -66,7 +66,7 @@ int DeConvolutionFp16CPUKernel::InitWeightBias() { return RET_ERROR; } memset(bias_data_, 0, UP_ROUND(output_channel, C8NUM) * sizeof(float16_t)); - if (in_tensors_.size() == 3) { + if (in_tensors_.size() == kInputSize2) { if (in_tensors_.at(kBiasIndex)->data_type() != kNumberTypeFloat16) { MS_LOG(ERROR) << "DeConv fp16 only support fp16 weight"; return RET_ERROR;