• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 convolutionress or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifdef ENABLE_SSE
17 #include "nnacl/kernel/convolution_im2col_sse.h"
18 #include "nnacl/fp32/pack_fp32.h"
19 #include "nnacl/tensor_c.h"
20 
ConvIm2ColSSEInitGlobalVariable(ConvolutionBaseStruct * conv)21 void ConvIm2ColSSEInitGlobalVariable(ConvolutionBaseStruct *conv) {
22   ConvolutionIm2ColBaseStruct *conv_im2col = (ConvolutionIm2ColBaseStruct *)conv;
23   conv_im2col->oc_tile_ = C8NUM;
24   conv_im2col->row_tile_ = C4NUM;
25   conv_im2col->row_major_to_col_nmajor_ = RowMajor2Col8Major;
26 }
27 
CreateConvIm2ColSSE(ConvParameter * conv_param)28 ConvolutionBaseStruct *CreateConvIm2ColSSE(ConvParameter *conv_param) {
29   ConvolutionIm2ColBaseStruct *conv_im2col = (ConvolutionIm2ColBaseStruct *)malloc(sizeof(ConvolutionIm2ColBaseStruct));
30   NNACL_MALLOC_CHECK_NULL_RETURN_NULL(conv_im2col);
31   memset(conv_im2col, 0, sizeof(ConvolutionIm2ColBaseStruct));
32 
33   conv_im2col->init_tmp_buffer_ = ConvIm2ColBaseInitTmpBuffer;
34 
35   conv_im2col->conv_.malloc_weight_bias_ = ConvIm2ColBaseMallocWeightBiasData;
36   conv_im2col->conv_.run_impl_ = ConvIm2ColBaseRunImpl;
37   conv_im2col->conv_.pack_weight_ = ConvIm2ColBasePackWeight;
38   conv_im2col->conv_.init_global_variable_ = ConvIm2ColSSEInitGlobalVariable;
39 
40   conv_im2col->conv_.base_.Compute = ConvolutionIm2colBaseCompute;
41   conv_im2col->conv_.base_.Prepare = ConvolutionIm2colBasePrepare;
42   conv_im2col->conv_.base_.Resize = ConvolutionIm2colBaseResize;
43   conv_im2col->conv_.base_.Release = ConvolutionIm2colBaseRelease;
44 
45   return (ConvolutionBaseStruct *)conv_im2col;
46 }
47 #endif
48