diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.cc index fff52c7c6ff9f08d5b01df461139c33882f5ff20..57ddcbb7bd1db653129596746339be1f1a82825a 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.cc @@ -27,7 +27,6 @@ using mindspore::schema::PrimitiveType_DetectionPostProcess; namespace mindspore::kernel { int DetectionPostProcessCPUKernel::Init() { - MS_ASSERT(context_->allocator != nullptr); auto anchor_tensor = in_tensors_.at(2); DetectionPostProcessParameter *parameter = reinterpret_cast(op_parameter_); parameter->anchors_ = nullptr; @@ -36,8 +35,7 @@ int DetectionPostProcessCPUKernel::Init() { const double scale = quant_params.at(0).scale; const int32_t zp = quant_params.at(0).zeroPoint; auto anchor_uint8 = reinterpret_cast(anchor_tensor->Data()); - auto anchor_fp32 = - reinterpret_cast(context_->allocator->Malloc(anchor_tensor->ElementsNum() * sizeof(float))); + auto anchor_fp32 = new (std::nothrow) float[anchor_tensor->ElementsNum()]; if (anchor_fp32 == nullptr) { MS_LOG(ERROR) << "Malloc anchor failed"; return RET_ERROR; @@ -47,7 +45,7 @@ int DetectionPostProcessCPUKernel::Init() { } parameter->anchors_ = anchor_fp32; } else if (anchor_tensor->data_type() == kNumberTypeFloat32) { - parameter->anchors_ = reinterpret_cast(context_->allocator->Malloc(anchor_tensor->Size())); + parameter->anchors_ = new (std::nothrow) float[anchor_tensor->ElementsNum()]; if (parameter->anchors_ == nullptr) { MS_LOG(ERROR) << "Malloc anchor failed"; return RET_ERROR; @@ -62,7 +60,7 @@ int DetectionPostProcessCPUKernel::Init() { DetectionPostProcessCPUKernel::~DetectionPostProcessCPUKernel() { DetectionPostProcessParameter *parameter = reinterpret_cast(op_parameter_); - context_->allocator->Free(parameter->anchors_); + delete [](parameter->anchors_); } int DetectionPostProcessCPUKernel::ReSize() { return RET_OK; }