1 /** 2 * Copyright 2023 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef NNACL_KERNEL_CONVOLLUTION_IM2COL_BASE_H_ 18 #define NNACL_KERNEL_CONVOLLUTION_IM2COL_BASE_H_ 19 20 #include "nnacl/op_base.h" 21 #include "nnacl/tensor_c.h" 22 #include "nnacl/kernel.h" 23 #include "nnacl/conv_parameter.h" 24 #include "nnacl/kernel/convolution_base.h" 25 26 typedef struct ConvolutionIm2ColBaseStruct { 27 ConvolutionBaseStruct conv_; 28 int oc_tile_; 29 int row_tile_; 30 31 float *tmp_output_; 32 float *packed_input_; 33 float *col_major_input_; 34 bool output_need_align_; 35 36 void (*row_major_to_col_nmajor_)(const float *src_ptr, float *dst_ptr, int row, int col); 37 int (*init_tmp_buffer_)(struct ConvolutionIm2ColBaseStruct *conv_im2col); 38 } ConvolutionIm2ColBaseStruct; 39 40 int ConvIm2ColBaseMallocWeightBiasData(ConvolutionBaseStruct *conv); 41 int ConvIm2ColBaseInitTmpBuffer(ConvolutionIm2ColBaseStruct *conv_im2col); 42 int ConvIm2ColBaseImpl(void *cdata, int task_id, float l, float r); 43 void ConvIm2ColBaseFreeTmpBuffer(ConvolutionIm2ColBaseStruct *conv_im2col); 44 void ConvIm2ColBasePackWeight(ConvolutionBaseStruct *conv); 45 int ConvIm2ColBaseRunImpl(ConvolutionBaseStruct *conv, int task_id); 46 int ConvolutionIm2colBaseCompute(KernelBase *self); 47 int ConvolutionIm2colBasePrepare(KernelBase *self); 48 int ConvolutionIm2colBaseResize(KernelBase *self); 49 int ConvolutionIm2colBaseRelease(KernelBase *self); 50 ConvolutionBaseStruct *CreateConvIm2ColBase(ConvParameter *conv_param); 51 52 #endif // NNACL_KERNEL_CONVOLLUTION_IM2COL_BASE_H_ 53