• 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 
17 #include "nnacl/kernel/convolution_im2col.h"
18 #include "nnacl/kernel/convolution_im2col_base.h"
19 #ifdef ENABLE_ARM32
20 #include "nnacl/kernel/convolution_im2col_arm32.h"
21 #endif
22 #ifdef ENABLE_ARM64
23 #include "nnacl/kernel/convolution_im2col_arm64.h"
24 #endif
25 #ifdef ENABLE_SSE
26 #include "nnacl/kernel/convolution_im2col_sse.h"
27 #endif
28 #ifdef ENABLE_AVX
29 #include "nnacl/kernel/convolution_im2col_avx.h"
30 #endif
31 #ifdef ENABLE_AVX512
32 #include "nnacl/intrinsics/ms_simd_cpu_info.h"
33 #include "nnacl/kernel/convolution_im2col_avx512.h"
34 #endif
35 
CreateConvolutionIm2Col(KernelBase * base,ConvParameter * conv_param)36 ConvolutionBaseStruct *CreateConvolutionIm2Col(KernelBase *base, ConvParameter *conv_param) {
37   ConvolutionBaseStruct *kernel = NULL;
38 
39 #ifdef ENABLE_AVX512
40   FormatC out_format = base->out_[OUTPUT_INDEX]->format_;
41   if (out_format != Format_NC4HW4) {
42     AVX512_HARDWARE_SELF_AWARENESS_BEGIN;
43     kernel = CreateConvIm2ColAVX512(conv_param);
44     if (kernel != NULL) {
45       return kernel;
46     }
47     AVX512_HARDWARE_SELF_AWARENESS_END;
48   }
49 #endif
50 
51 #ifdef ENABLE_AVX
52   kernel = CreateConvIm2ColAVX(conv_param);
53   if (kernel != NULL) {
54     return kernel;
55   }
56 #endif
57 
58 #ifdef ENABLE_SSE
59   kernel = CreateConvIm2ColSSE(conv_param);
60   if (kernel != NULL) {
61     return kernel;
62   }
63 #endif
64 
65 #ifdef ENABLE_ARM64
66   kernel = CreateConvIm2ColARM64(conv_param);
67   if (kernel != NULL) {
68     return kernel;
69   }
70 #endif
71 
72 #ifdef ENABLE_ARM32
73   kernel = CreateConvIm2ColARM32(conv_param);
74   if (kernel != NULL) {
75     return kernel;
76   }
77 #endif
78 
79   kernel = CreateConvIm2ColBase(conv_param);
80   return kernel;
81 }
82