Merge pull request !4661 from ling/conv1x1_fp16tags/v0.7.0-beta
| @@ -105,16 +105,24 @@ int Convolution1x1FP16CPUKernel::Init() { | |||||
| return ReSize(); | return ReSize(); | ||||
| } | } | ||||
| int Convolution1x1FP16CPUKernel::ReSize() { | |||||
| FreeTmpBuffer(); | |||||
| if (fp16_weight_ != nullptr) { | |||||
| free(fp16_weight_); | |||||
| fp16_weight_ = nullptr; | |||||
| void Convolution1x1FP16CPUKernel::FreeTmpBuffer() { | |||||
| if (weight_ptr_ != nullptr) { | |||||
| free(weight_ptr_); | |||||
| weight_ptr_ = nullptr; | |||||
| } | } | ||||
| if (input_ptr_ != nullptr) { | |||||
| if (pack_input_ != nullptr) { | |||||
| free(pack_input_); | |||||
| pack_input_ = nullptr; | |||||
| } | |||||
| if (pre_trans_input_ && input_ptr_ != nullptr) { | |||||
| free(input_ptr_); | free(input_ptr_); | ||||
| input_ptr_ = nullptr; | input_ptr_ = nullptr; | ||||
| } | } | ||||
| return; | |||||
| } | |||||
| int Convolution1x1FP16CPUKernel::ReSize() { | |||||
| FreeTmpBuffer(); | |||||
| auto ret = ConvolutionBaseCPUKernel::Init(); | auto ret = ConvolutionBaseCPUKernel::Init(); | ||||
| if (ret != RET_OK) { | if (ret != RET_OK) { | ||||
| @@ -34,33 +34,27 @@ class Convolution1x1FP16CPUKernel : public ConvolutionBaseFP16CPUKernel { | |||||
| : ConvolutionBaseFP16CPUKernel(parameter, inputs, outputs, ctx, primitive) { | : ConvolutionBaseFP16CPUKernel(parameter, inputs, outputs, ctx, primitive) { | ||||
| matmul_param_ = new MatMulParameter(); | matmul_param_ = new MatMulParameter(); | ||||
| } | } | ||||
| ~Convolution1x1FP16CPUKernel() override { FreeTmpBuffer(); } | |||||
| ~Convolution1x1FP16CPUKernel() override { | |||||
| FreeTmpBuffer(); | |||||
| if (matmul_param_ != nullptr) { | |||||
| delete matmul_param_; | |||||
| matmul_param_ = nullptr; | |||||
| } | |||||
| } | |||||
| int Init() override; | int Init() override; | ||||
| int ReSize() override; | int ReSize() override; | ||||
| int Run() override; | int Run() override; | ||||
| int RunImpl(int task_id); | int RunImpl(int task_id); | ||||
| int InitBuffer(); | |||||
| private: | |||||
| void FreeTmpBuffer(); | |||||
| int InitConv1x1Param(); | int InitConv1x1Param(); | ||||
| int InitMatmulParam(); | int InitMatmulParam(); | ||||
| int InitWeightBias(); | int InitWeightBias(); | ||||
| void Pre1x1Trans(float16_t *src_input, float16_t *src_output); | void Pre1x1Trans(float16_t *src_input, float16_t *src_output); | ||||
| private: | private: | ||||
| void FreeTmpBuffer() { | |||||
| if (weight_ptr_ != nullptr) { | |||||
| free(weight_ptr_); | |||||
| weight_ptr_ = nullptr; | |||||
| } | |||||
| if (matmul_param_ != nullptr) { | |||||
| delete matmul_param_; | |||||
| matmul_param_ = nullptr; | |||||
| } | |||||
| if (pack_input_ != nullptr) { | |||||
| free(pack_input_); | |||||
| pack_input_ = nullptr; | |||||
| } | |||||
| } | |||||
| bool pre_trans_input_ = false; | bool pre_trans_input_ = false; | ||||
| int thread_count_ = 0; | int thread_count_ = 0; | ||||
| int thread_stride_ = 0; | int thread_stride_ = 0; | ||||
| @@ -27,6 +27,10 @@ using mindspore::schema::PrimitiveType_DeConv2D; | |||||
| namespace mindspore::kernel { | namespace mindspore::kernel { | ||||
| DeConvolutionFp16CPUKernel::~DeConvolutionFp16CPUKernel() { | DeConvolutionFp16CPUKernel::~DeConvolutionFp16CPUKernel() { | ||||
| FreeParam(); | FreeParam(); | ||||
| if (matmul_param_ != nullptr) { | |||||
| delete matmul_param_; | |||||
| matmul_param_ = nullptr; | |||||
| } | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -26,6 +26,7 @@ Convolution1x1CPUKernel::~Convolution1x1CPUKernel() { | |||||
| FreeTmpBuffer(); | FreeTmpBuffer(); | ||||
| if (matmul_param_ != nullptr) { | if (matmul_param_ != nullptr) { | ||||
| delete matmul_param_; | delete matmul_param_; | ||||
| matmul_param_ = nullptr; | |||||
| } | } | ||||
| } | } | ||||
| @@ -42,6 +43,7 @@ void Convolution1x1CPUKernel::FreeTmpBuffer() { | |||||
| free(input_ptr_); | free(input_ptr_); | ||||
| input_ptr_ = nullptr; | input_ptr_ = nullptr; | ||||
| } | } | ||||
| return; | |||||
| } | } | ||||
| int Convolution1x1CPUKernel::ReSize() { | int Convolution1x1CPUKernel::ReSize() { | ||||
| @@ -25,7 +25,13 @@ using mindspore::lite::RET_OK; | |||||
| using mindspore::schema::PrimitiveType_DeConv2D; | using mindspore::schema::PrimitiveType_DeConv2D; | ||||
| namespace mindspore::kernel { | namespace mindspore::kernel { | ||||
| DeConvolutionCPUKernel::~DeConvolutionCPUKernel() { FreeTmpBuffer(); } | |||||
| DeConvolutionCPUKernel::~DeConvolutionCPUKernel() { | |||||
| FreeTmpBuffer(); | |||||
| if (matmul_param_ != nullptr) { | |||||
| delete matmul_param_; | |||||
| matmul_param_ = nullptr; | |||||
| } | |||||
| } | |||||
| void DeConvolutionCPUKernel::FreeTmpBuffer() { | void DeConvolutionCPUKernel::FreeTmpBuffer() { | ||||
| if (weight_ptr_ != nullptr) { | if (weight_ptr_ != nullptr) { | ||||
| @@ -44,6 +50,7 @@ void DeConvolutionCPUKernel::FreeTmpBuffer() { | |||||
| free(pack_output_); | free(pack_output_); | ||||
| pack_output_ = nullptr; | pack_output_ = nullptr; | ||||
| } | } | ||||
| return; | |||||
| } | } | ||||
| int DeConvolutionCPUKernel::ReSize() { | int DeConvolutionCPUKernel::ReSize() { | ||||