diff --git a/mindspore/lite/src/common/string_util.cc b/mindspore/lite/src/common/string_util.cc index bdfa6cb823..9a77f285e4 100644 --- a/mindspore/lite/src/common/string_util.cc +++ b/mindspore/lite/src/common/string_util.cc @@ -115,6 +115,9 @@ int GetStringCount(const void *data) { return *(static_cast(dat int GetStringCount(Tensor *tensor) { return GetStringCount(tensor->MutableData()); } int StringsToMSTensor(const std::vector &inputs, tensor::MSTensor *tensor) { + if (tensor == nullptr) { + return RET_PARAM_INVALID; + } std::vector all_pack; for (auto &input : inputs) { StringPack pack = {static_cast(input.length()), input.data()}; @@ -124,6 +127,9 @@ int StringsToMSTensor(const std::vector &inputs, tensor::MSTensor * } std::vector MSTensorToStrings(const tensor::MSTensor *tensor) { + if (tensor == nullptr) { + return {""}; + } const void *ptr = static_cast(tensor)->data_c(); std::vector all_pack = ParseStringBuffer(ptr); std::vector result(all_pack.size()); diff --git a/mindspore/lite/src/runtime/kernel/arm/base/arg_min_max_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/arg_min_max_base.cc index 2e2164fb3a..1c03a63510 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/arg_min_max_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/arg_min_max_base.cc @@ -104,9 +104,9 @@ kernel::LiteKernel *CpuArgMinMaxFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/batch_to_space_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/batch_to_space_base.cc index b1c62ed5a5..55c0e339c8 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/batch_to_space_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/batch_to_space_base.cc @@ -70,9 +70,9 @@ kernel::LiteKernel *CpuBatchToSpaceFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/concat_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/concat_base.cc index 05418a54a0..e8ffc1aa46 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/concat_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/concat_base.cc @@ -51,9 +51,9 @@ kernel::LiteKernel *CpuConcatInt32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; @@ -76,9 +76,9 @@ kernel::LiteKernel *CpuConcatFp32KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/crop_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/crop_base.cc index b497f9c47f..e8ac28d63d 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/crop_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/crop_base.cc @@ -98,9 +98,9 @@ kernel::LiteKernel *CpuCropInt32KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; @@ -123,9 +123,9 @@ kernel::LiteKernel *CpuCropFp32KernelCreator(const std::vector & } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/depth_to_space_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/depth_to_space_base.cc index eecdc03411..63278f7d41 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/depth_to_space_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/depth_to_space_base.cc @@ -79,9 +79,9 @@ kernel::LiteKernel *CpuDepthToSpaceFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/fullconnection_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/fullconnection_base.cc index 29094c06d1..83cac47167 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/fullconnection_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/fullconnection_base.cc @@ -66,7 +66,6 @@ kernel::LiteKernel *CpuFullConnectionFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); if (dequant_flag) { @@ -74,6 +73,7 @@ kernel::LiteKernel *CpuFullConnectionFp32KernelCreator(const std::vectorset_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } if (dequant_flag) { diff --git a/mindspore/lite/src/runtime/kernel/arm/base/matmul_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/matmul_base.cc index 0ef4ca3414..14e1eb83e3 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/matmul_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/matmul_base.cc @@ -45,9 +45,9 @@ kernel::LiteKernel *CpuMatmulKernelCreator(const std::vector &in } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/pad.cc b/mindspore/lite/src/runtime/kernel/arm/base/pad.cc index 180d42ea4e..38d8887b62 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/pad.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/pad.cc @@ -41,9 +41,9 @@ kernel::LiteKernel *CpuPadFp32KernelCreator(const std::vector &i } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/pooling_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/pooling_base.cc index d816f4dadd..45ea45438f 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/pooling_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/pooling_base.cc @@ -47,8 +47,8 @@ int PoolingBaseCPUKernel::SetQuantParam() { if (pooling_quant_arg_[1] == nullptr) { MS_LOG(ERROR) << "malloc pooling_quant_arg[1] failed."; free(pooling_quant_arg_[0]); - free(pooling_quant_arg_); pooling_quant_arg_[0] = nullptr; + free(pooling_quant_arg_); pooling_quant_arg_ = nullptr; return RET_MEMORY_FAILED; } @@ -127,9 +127,9 @@ kernel::LiteKernel *CpuPoolingFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/power_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/power_base.cc index 8d0d7b1c53..fe552c3d9e 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/power_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/power_base.cc @@ -44,9 +44,9 @@ kernel::LiteKernel *CpuPowerFp32KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/prior_box.cc b/mindspore/lite/src/runtime/kernel/arm/base/prior_box.cc index 0a759c8a08..6b5db11559 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/prior_box.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/prior_box.cc @@ -44,8 +44,8 @@ int PriorBoxCPUKernel::Init() { MS_LOG(ERROR) << "Size of input tensors is wrong."; return RET_ERROR; } - if (in_tensors_.size() != kOutputNum) { - MS_LOG(ERROR) << "Size of input tensors is wrong."; + if (out_tensors_.size() != kOutputNum) { + MS_LOG(ERROR) << "Size of output tensors is wrong."; return RET_ERROR; } @@ -195,9 +195,9 @@ kernel::LiteKernel *CpuPriorBoxKernelCreator(const std::vector & } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/reshape_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/reshape_base.cc index 9d5bb4c23b..56f2fa5d73 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/reshape_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/reshape_base.cc @@ -46,9 +46,9 @@ kernel::LiteKernel *CpuReshapeInt32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; @@ -71,9 +71,9 @@ kernel::LiteKernel *CpuReshapeFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/resize_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/resize_base.cc index d6a966a804..e1eb38b527 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/resize_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/resize_base.cc @@ -144,9 +144,9 @@ kernel::LiteKernel *CpuResizeFp32KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } diff --git a/mindspore/lite/src/runtime/kernel/arm/base/softmax_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/softmax_base.cc index 6b24bfcb97..1d7a6e08d9 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/softmax_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/softmax_base.cc @@ -72,9 +72,9 @@ kernel::LiteKernel *CpuSoftmaxFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/base/split_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/split_base.cc index 67f774c045..3d6cdbddf0 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/split_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/split_base.cc @@ -119,9 +119,9 @@ kernel::LiteKernel *CpuSplitFp32KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/activation_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/activation_fp16.cc index 84d4a39674..4cf00d8b96 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/activation_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/activation_fp16.cc @@ -150,9 +150,9 @@ kernel::LiteKernel *CpuActivationFp16KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/cast_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/cast_fp16.cc index 70b4b08eaf..c41a8d0b76 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/cast_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/cast_fp16.cc @@ -154,9 +154,9 @@ kernel::LiteKernel *CpuCastFp16KernelCreator(const std::vector & } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_depthwise_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_depthwise_fp16.cc index 6bed2282eb..39e24d130c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_depthwise_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_depthwise_fp16.cc @@ -174,7 +174,6 @@ kernel::LiteKernel *CpuConvDwFp16KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); if (dequant_flag) { @@ -182,6 +181,7 @@ kernel::LiteKernel *CpuConvDwFp16KernelCreator(const std::vector weight_tensor->set_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } if (dequant_flag) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc index 3f74a3cf0b..e4fbb687f0 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc @@ -464,7 +464,6 @@ kernel::LiteKernel *CpuConvFp16KernelCreator(const std::vector & } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(INFO) << "Init fp16 kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); if (dequant_flag) { @@ -472,6 +471,7 @@ kernel::LiteKernel *CpuConvFp16KernelCreator(const std::vector & weight_tensor->set_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } if (dequant_flag) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/crop_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/crop_fp16.cc index 047ada5fb4..63cbc3f913 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/crop_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/crop_fp16.cc @@ -110,9 +110,9 @@ kernel::LiteKernel *CpuCropFp16KernelCreator(const std::vector & } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_depthwise_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_depthwise_fp16.cc index 54bceb7514..eadbd553cf 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_depthwise_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_depthwise_fp16.cc @@ -241,7 +241,6 @@ kernel::LiteKernel *CpuDeconvDwFp16KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); if (dequant_flag) { @@ -249,6 +248,7 @@ kernel::LiteKernel *CpuDeconvDwFp16KernelCreator(const std::vectorset_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } if (dequant_flag) { 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 e886b3da71..1b59471413 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc @@ -167,6 +167,11 @@ int DeConvolutionFp16CPUKernel::DoDeconv(int task_id) { } int DeConvolutionFp16CPUKernel::Init() { + matmul_param_ = new (std::nothrow) MatMulParameter(); + if (matmul_param_ == nullptr) { + MS_LOG(ERROR) << "Memory allocation failed"; + return RET_ERROR; + } int ret = InitWeightBias(); if (ret != RET_OK) { MS_LOG(ERROR) << "deconv InitWeightBias error!"; @@ -251,7 +256,6 @@ kernel::LiteKernel *CpuDeConvFp16KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); if (dequant_flag) { @@ -259,6 +263,7 @@ kernel::LiteKernel *CpuDeConvFp16KernelCreator(const std::vector weight_tensor->set_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } if (dequant_flag) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.h b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.h index f9f0d0fc2b..4911fdb320 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.h @@ -29,12 +29,7 @@ class DeConvolutionFp16CPUKernel : public ConvolutionBaseFP16CPUKernel { DeConvolutionFp16CPUKernel(OpParameter *parameter, const std::vector &inputs, const std::vector &outputs, const lite::InnerContext *ctx, const mindspore::lite::PrimitiveC *primitive) - : ConvolutionBaseFP16CPUKernel(parameter, inputs, outputs, ctx, primitive) { - matmul_param_ = new (std::nothrow) MatMulParameter(); - if (matmul_param_ == nullptr) { - MS_LOG(ERROR) << "new MatMulParameter fail!"; - } - } + : ConvolutionBaseFP16CPUKernel(parameter, inputs, outputs, ctx, primitive) {} ~DeConvolutionFp16CPUKernel() override; int Init() override; int Run() override; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_winograd_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_winograd_fp16.cc index 0de1a1bf29..c2d8d8daa9 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_winograd_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_winograd_fp16.cc @@ -361,6 +361,16 @@ int DeConvWinogradFp16CPUKernel::ReSize() { } int DeConvWinogradFp16CPUKernel::Init() { + deconv_param_ = new (std::nothrow) DeConvParam(); + if (deconv_param_ == nullptr) { + MS_LOG(ERROR) << "Memory allocation failed"; + return RET_ERROR; + } + for (auto &wg : deconv_param_->a_buffer_) { + wg.buf_init_ = false; + wg.dest_buffer_ = nullptr; + wg.middle_buffer_ = nullptr; + } int error_code = InitComputeParam(); if (error_code != RET_OK) { MS_LOG(ERROR) << "InitComputeParam error! ret: " << error_code; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_winograd_fp16.h b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_winograd_fp16.h index 45b1c6cc98..3eeaad2f77 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_winograd_fp16.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_winograd_fp16.h @@ -30,14 +30,7 @@ class DeConvWinogradFp16CPUKernel : public ConvolutionBaseFP16CPUKernel { DeConvWinogradFp16CPUKernel(OpParameter *parameter, const std::vector &inputs, const std::vector &outputs, const lite::InnerContext *ctx, const mindspore::lite::PrimitiveC *primitive) - : ConvolutionBaseFP16CPUKernel(parameter, inputs, outputs, ctx, primitive) { - deconv_param_ = new DeConvParam(); - for (auto &wg : deconv_param_->a_buffer_) { - wg.buf_init_ = false; - wg.dest_buffer_ = nullptr; - wg.middle_buffer_ = nullptr; - } - } + : ConvolutionBaseFP16CPUKernel(parameter, inputs, outputs, ctx, primitive) {} ~DeConvWinogradFp16CPUKernel() override; int Init() override; int Run() override; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/fullconnection_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/fullconnection_fp16.cc index 9b2e731efa..18ed44385b 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/fullconnection_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/fullconnection_fp16.cc @@ -269,12 +269,12 @@ kernel::LiteKernel *CpuFullConnectionFp16KernelCreator(const std::vectorname_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - delete kernel; if (dequant_flag) { weight_tensor->FreeData(); weight_tensor->set_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } if (dequant_flag) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/fused_batchnorm_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/fused_batchnorm_fp16.cc index 1aae6270e1..1e0489496f 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/fused_batchnorm_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/fused_batchnorm_fp16.cc @@ -96,9 +96,9 @@ kernel::LiteKernel *CpuFusedBatchnormFp16KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/pooling_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/pooling_fp16.cc index 71e89c5334..3f6e8bf566 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/pooling_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/pooling_fp16.cc @@ -129,9 +129,9 @@ kernel::LiteKernel *CpuPoolingFp16KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/reshape_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/reshape_fp16.cc index b0c4cbc2f7..bd6c551668 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/reshape_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/reshape_fp16.cc @@ -86,9 +86,9 @@ kernel::LiteKernel *CpuReshapeFp16KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/scale_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/scale_fp16.cc index f6458eb29e..38b9bf0a7d 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/scale_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/scale_fp16.cc @@ -119,6 +119,7 @@ int ScaleFp16CPUKernel::Run() { ret = ParallelLaunch(this->context_->thread_pool_, ScaleFp16Run, this, op_parameter_->thread_num_); if (ret != RET_OK) { MS_LOG(ERROR) << "Scale error error_code[" << ret << "]"; + FreeTmpBuffer(); return RET_ERROR; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/softmax_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/softmax_fp16.cc index f7f2b8dff2..f30048a83e 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/softmax_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/softmax_fp16.cc @@ -136,9 +136,9 @@ kernel::LiteKernel *CpuSoftmaxFp16KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/split_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/split_fp16.cc index d12ff4c7ae..36571ad00c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/split_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/split_fp16.cc @@ -133,9 +133,9 @@ kernel::LiteKernel *CpuSplitFp16KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/stack_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/stack_fp16.cc index 36bfa97304..d5690b4f33 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/stack_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/stack_fp16.cc @@ -118,9 +118,9 @@ kernel::LiteKernel *CpuStackFp16KernelCreator(const std::vector auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.cc index 1f87b125bc..ec19a8472c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/activation_fp32.cc @@ -118,9 +118,9 @@ kernel::LiteKernel *CpuActivationFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/broadcast_to_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/broadcast_to_fp32.cc index 5747d49e30..3ddc28d9f1 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/broadcast_to_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/broadcast_to_fp32.cc @@ -74,9 +74,9 @@ kernel::LiteKernel *CpuBroadcastToFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/cast_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/cast_fp32.cc index a38db5ef17..ea93db34b4 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/cast_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/cast_fp32.cc @@ -153,9 +153,9 @@ kernel::LiteKernel *CpuCastFp32KernelCreator(const std::vector & } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1_fp32.cc index 65b4d6f241..261215d386 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1_fp32.cc @@ -126,6 +126,11 @@ int Convolution1x1CPUKernel::InitConv1x1Param() { } int Convolution1x1CPUKernel::Init() { + matmul_param_ = new (std::nothrow) MatMulParameter; + if (matmul_param_ == nullptr) { + MS_LOG(ERROR) << "Memory allocation failed"; + return RET_ERROR; + } int error_code = InitConv1x1BiasWeight(); if (error_code != RET_OK) { MS_LOG(ERROR) << "Convolution base init failed."; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1_fp32.h b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1_fp32.h index cfebe35e00..342ca4c5b2 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1_fp32.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_1x1_fp32.h @@ -36,12 +36,7 @@ class Convolution1x1CPUKernel : public ConvolutionBaseCPUKernel { Convolution1x1CPUKernel(OpParameter *parameter, const std::vector &inputs, const std::vector &outputs, const lite::InnerContext *ctx, const mindspore::lite::PrimitiveC *primitive) - : ConvolutionBaseCPUKernel(parameter, inputs, outputs, ctx, primitive) { - matmul_param_ = new (std::nothrow) MatMulParameter(); - if (matmul_param_ == nullptr) { - MS_LOG(ERROR) << "new MatMulParameter fail!"; - } - } + : ConvolutionBaseCPUKernel(parameter, inputs, outputs, ctx, primitive) {} ~Convolution1x1CPUKernel(); int Init() override; int Run() override; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_depthwise_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_depthwise_fp32.cc index 4368e30ef6..4b46c6ede1 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_depthwise_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_depthwise_fp32.cc @@ -169,7 +169,6 @@ kernel::LiteKernel *CpuConvDwFp32KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK && ret != RET_INFER_INVALID) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); if (weight_tensor->data_type() == kNumberTypeInt8 || weight_tensor->data_type() == kNumberTypeInt16) { @@ -177,6 +176,7 @@ kernel::LiteKernel *CpuConvDwFp32KernelCreator(const std::vector weight_tensor->set_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_fp32.cc index ae12237fba..e8d9a26874 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/convolution_fp32.cc @@ -440,7 +440,6 @@ kernel::LiteKernel *CpuConvFp32KernelCreator(const std::vector & } auto ret = kernel->Init(); if (ret != RET_OK && ret != RET_INFER_INVALID) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); if (dequant_flag) { @@ -448,6 +447,7 @@ kernel::LiteKernel *CpuConvFp32KernelCreator(const std::vector & weight_tensor->set_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_depthwise_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_depthwise_fp32.cc index 5897492979..7edb7037cb 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_depthwise_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_depthwise_fp32.cc @@ -230,7 +230,6 @@ kernel::LiteKernel *CpuDeconvDwFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); if (dequant_flag) { @@ -238,6 +237,7 @@ kernel::LiteKernel *CpuDeconvDwFp32KernelCreator(const std::vectorset_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } if (dequant_flag) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_fp32.cc index a8654ddc31..fa5f929986 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_fp32.cc @@ -134,6 +134,11 @@ int DeConvolutionCPUKernel::DoDeconv(int task_id) { } int DeConvolutionCPUKernel::Init() { + matmul_param_ = new (std::nothrow) MatMulParameter(); + if (matmul_param_ == nullptr) { + MS_LOG(ERROR) << "Memory allocation failed"; + return RET_ERROR; + } int error_code = InitWeightBias(); if (error_code != RET_OK) { MS_LOG(ERROR) << "deconv InitWeightBias error!ret: " << error_code; @@ -270,7 +275,6 @@ kernel::LiteKernel *CpuDeConvFp32KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); if (dequant_flag) { @@ -278,6 +282,7 @@ kernel::LiteKernel *CpuDeConvFp32KernelCreator(const std::vector weight_tensor->set_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_fp32.h b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_fp32.h index 593d9eec82..5d29ba5477 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_fp32.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_fp32.h @@ -33,9 +33,7 @@ class DeConvolutionCPUKernel : public ConvolutionBaseCPUKernel { DeConvolutionCPUKernel(OpParameter *parameter, const std::vector &inputs, const std::vector &outputs, const lite::InnerContext *ctx, const mindspore::lite::PrimitiveC *primitive) - : ConvolutionBaseCPUKernel(parameter, inputs, outputs, ctx, primitive) { - matmul_param_ = new MatMulParameter(); - } + : ConvolutionBaseCPUKernel(parameter, inputs, outputs, ctx, primitive) {} ~DeConvolutionCPUKernel() override; int Init() override; int Run() override; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_winograd_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_winograd_fp32.cc index b5aa53bd6e..b1e5b9aa19 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_winograd_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_winograd_fp32.cc @@ -301,6 +301,14 @@ int DeConvolutionWinogradCPUKernel::ReSize() { } int DeConvolutionWinogradCPUKernel::Init() { + deconv_param_ = new (std::nothrow) DeConvParam(); + if (deconv_param_ == nullptr) { + MS_LOG(ERROR) << "Memory allocation failed"; + return RET_ERROR; + } + for (auto &wg : deconv_param_->a_buffer_) { + wg.buf_init_ = false; + } int error_code = InitComputeParam(); if (error_code != RET_OK) { MS_LOG(ERROR) << "InitComputeParam error! ret: " << error_code; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_winograd_fp32.h b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_winograd_fp32.h index f949066606..03946adefc 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_winograd_fp32.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_winograd_fp32.h @@ -33,12 +33,7 @@ class DeConvolutionWinogradCPUKernel : public ConvolutionBaseCPUKernel { DeConvolutionWinogradCPUKernel(OpParameter *parameter, const std::vector &inputs, const std::vector &outputs, const lite::InnerContext *ctx, const mindspore::lite::PrimitiveC *primitive) - : ConvolutionBaseCPUKernel(parameter, inputs, outputs, ctx, primitive) { - deconv_param_ = new DeConvParam(); - for (auto &wg : deconv_param_->a_buffer_) { - wg.buf_init_ = false; - } - } + : ConvolutionBaseCPUKernel(parameter, inputs, outputs, ctx, primitive) {} ~DeConvolutionWinogradCPUKernel() override; int Init() override; int Run() override; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/fused_batchnorm_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/fused_batchnorm_fp32.cc index ba5d28b6a5..156cc41ade 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/fused_batchnorm_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/fused_batchnorm_fp32.cc @@ -143,9 +143,9 @@ kernel::LiteKernel *CpuFusedBatchnormKernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/lstm_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/lstm_fp32.cc index 1f8b6401dd..cfd72a2991 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/lstm_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/lstm_fp32.cc @@ -195,9 +195,9 @@ kernel::LiteKernel *CpuLstmKernelCreator(const std::vector &inpu } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32.cc index c1cfd09545..e38a0b3eb0 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32.cc @@ -428,7 +428,6 @@ kernel::LiteKernel *CpuMatmulFp32KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); if (dequant_flag) { @@ -436,6 +435,7 @@ kernel::LiteKernel *CpuMatmulFp32KernelCreator(const std::vector weight_tensor->set_data(restore_data); weight_tensor->set_data_type(restore_type); } + delete kernel; return nullptr; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/non_max_suppression_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/non_max_suppression_fp32.cc index a444145f8e..738b3cf46e 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/non_max_suppression_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/non_max_suppression_fp32.cc @@ -236,9 +236,9 @@ kernel::LiteKernel *CpuNonMaxSuppressionFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/one_hot_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/one_hot_fp32.cc index bc32453c69..1eeb8afdfa 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/one_hot_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/one_hot_fp32.cc @@ -206,9 +206,9 @@ kernel::LiteKernel *CpuOneHotFp32KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/reverse_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/reverse_fp32.cc index 47ed9878a1..3704bd2183 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/reverse_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/reverse_fp32.cc @@ -154,9 +154,9 @@ kernel::LiteKernel *CpuReverseFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/roi_pooling_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/roi_pooling_fp32.cc index e009e1c1ba..5c4eb45780 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/roi_pooling_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/roi_pooling_fp32.cc @@ -135,9 +135,9 @@ kernel::LiteKernel *CpuROIPoolingFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/slice_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/slice_fp32.cc index dd916fa0f0..4b8bc92124 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/slice_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/slice_fp32.cc @@ -103,9 +103,9 @@ kernel::LiteKernel *CpuSliceFp32KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/space_to_depth_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/space_to_depth_fp32.cc index a5abe1074f..988d2bae32 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/space_to_depth_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/space_to_depth_fp32.cc @@ -121,9 +121,9 @@ kernel::LiteKernel *CpuSpaceToDepthFp32KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/stack_fp32.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/stack_fp32.cc index 3ce64362de..0264a4509b 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/stack_fp32.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/stack_fp32.cc @@ -94,9 +94,9 @@ kernel::LiteKernel *CpuStackFp32KernelCreator(const std::vector auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/activation_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/activation_int8.cc index c21672094c..33d772edb9 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/activation_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/activation_int8.cc @@ -71,9 +71,9 @@ kernel::LiteKernel *CpuActivationInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/argminmax_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/argminmax_int8.cc index f26d48b40b..7d824184f3 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/argminmax_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/argminmax_int8.cc @@ -100,9 +100,9 @@ kernel::LiteKernel *CpuArgMinMaxInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/batch_to_space_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/batch_to_space_int8.cc index fd760b6094..cec88389b8 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/batch_to_space_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/batch_to_space_int8.cc @@ -99,9 +99,9 @@ kernel::LiteKernel *CpuBatchToSpaceInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/concat_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/concat_int8.cc index cae32f1224..4dc3b2b1f5 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/concat_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/concat_int8.cc @@ -157,9 +157,9 @@ kernel::LiteKernel *CpuConcatInt8KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/convolution_depthwise_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/convolution_depthwise_int8.cc index 81ebec4f77..3a0d1813a7 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/convolution_depthwise_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/convolution_depthwise_int8.cc @@ -203,9 +203,9 @@ kernel::LiteKernel *CpuConvDwInt8KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/convolution_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/convolution_int8.cc index 39591176bb..e75b3a0e17 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/convolution_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/convolution_int8.cc @@ -274,9 +274,9 @@ kernel::LiteKernel *CpuConvInt8KernelCreator(const std::vector & } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/crop_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/crop_int8.cc index bbf0a89c76..c86ca1e5ee 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/crop_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/crop_int8.cc @@ -104,9 +104,9 @@ kernel::LiteKernel *CpuCropInt8KernelCreator(const std::vector & } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/deconvolution_depthwise_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/deconvolution_depthwise_int8.cc index 4813f2a26f..2f2931fb87 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/deconvolution_depthwise_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/deconvolution_depthwise_int8.cc @@ -227,9 +227,9 @@ kernel::LiteKernel *CpuDeconvDwInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; 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 9f53921b24..642381d786 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/deconvolution_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/deconvolution_int8.cc @@ -291,9 +291,9 @@ kernel::LiteKernel *CpuDeConvInt8KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/depth_to_space_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/depth_to_space_int8.cc index d541dfd25b..1fa8235ca8 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/depth_to_space_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/depth_to_space_int8.cc @@ -88,9 +88,9 @@ kernel::LiteKernel *CpuDepthToSpaceInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc index 49f4d0241c..57f3b0f1fe 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc @@ -290,9 +290,9 @@ kernel::LiteKernel *CpuFullConnectionInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc index 84690fa4db..4723c96d87 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc @@ -154,9 +154,9 @@ kernel::LiteKernel *CpuLeakyReluInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/matmul_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/matmul_int8.cc index a8e88edebe..649858958a 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/matmul_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/matmul_int8.cc @@ -212,9 +212,9 @@ kernel::LiteKernel *CpuMatMulInt8KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/mul_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/mul_int8.cc index 93ae94c5bb..04558658ca 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/mul_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/mul_int8.cc @@ -236,9 +236,9 @@ kernel::LiteKernel *CpuMulInt8KernelCreator(const std::vector &i } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc index d901eb70e9..fa9ae52eb0 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc @@ -303,9 +303,9 @@ kernel::LiteKernel *CpuPadInt8KernelCreator(const std::vector &i } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/pooling_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/pooling_int8.cc index a6542e4bf8..b0465a76e2 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/pooling_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/pooling_int8.cc @@ -120,9 +120,9 @@ kernel::LiteKernel *CpuPoolingInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/power_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/power_int8.cc index 57abe0b883..56ecf17493 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/power_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/power_int8.cc @@ -129,9 +129,9 @@ kernel::LiteKernel *CpuPowerInt8KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/reshape_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/reshape_int8.cc index 511f4a834d..51557f6a35 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/reshape_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/reshape_int8.cc @@ -99,9 +99,9 @@ kernel::LiteKernel *CpuReshapeInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/resize_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/resize_int8.cc index 55b19c6804..48492c4e8c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/resize_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/resize_int8.cc @@ -73,9 +73,12 @@ int ResizeInt8CPUKernel::Init() { return ret; } quant_in_ = new (std::nothrow) QuantArg; - MS_ASSERT(quant_in_); quant_out_ = new (std::nothrow) QuantArg; - MS_ASSERT(quant_out_); + multiplier_ = new (std::nothrow) QuantMulArg; + if (quant_in_ == nullptr || quant_out_ == nullptr || multiplier_ == nullptr) { + MS_LOG(ERROR) << "Memory allocation failed"; + return RET_ERROR; + } auto input = in_tensors_.at(0); quant_in_->zp_ = input->quant_params().front().zeroPoint; quant_in_->scale_ = input->quant_params().front().scale; @@ -83,8 +86,6 @@ int ResizeInt8CPUKernel::Init() { quant_out_->zp_ = output->quant_params().front().zeroPoint; quant_out_->scale_ = output->quant_params().front().scale; - multiplier_ = new (std::nothrow) QuantMulArg; - MS_ASSERT(multiplier_); QuantizeRoundParameter(quant_in_->scale_ / quant_out_->scale_, &multiplier_->multiplier_, &multiplier_->left_shift_, &multiplier_->right_shift_); if (!InferShapeDone()) { @@ -379,9 +380,9 @@ kernel::LiteKernel *CpuResizeInt8KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc index 732b9f67b2..dc403a33e7 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc @@ -147,9 +147,9 @@ kernel::LiteKernel *CpuSoftmaxInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/split_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/split_int8.cc index a4458da10f..2a074fac02 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/split_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/split_int8.cc @@ -123,9 +123,9 @@ kernel::LiteKernel *CpuSplitInt8KernelCreator(const std::vector } auto ret = kernel->Init(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel; diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/squeeze_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/squeeze_int8.cc index 866a539899..8369fae72c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/squeeze_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/squeeze_int8.cc @@ -139,9 +139,9 @@ kernel::LiteKernel *CpuSqueezeInt8KernelCreator(const std::vectorInit(); if (ret != RET_OK) { - delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; return nullptr; } return kernel;