• 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_winograd.h"
18 #include "nnacl/kernel/convolution_winograd_base.h"
19 #ifdef ENABLE_AVX
20 #include "nnacl/kernel/convolution_winograd_avx.h"
21 #endif
22 #ifdef ENABLE_SSE
23 #include "nnacl/kernel/convolution_winograd_sse.h"
24 #endif
25 #ifdef ENABLE_ARM64
26 #include "nnacl/kernel/convolution_winograd_arm64.h"
27 #endif
28 #ifdef ENABLE_ARM32
29 #include "nnacl/kernel/convolution_winograd_arm32.h"
30 #endif
31 
SelectConvolutionWinograd(ConvParameter * conv_param)32 ConvolutionWinogradBaseStruct *SelectConvolutionWinograd(ConvParameter *conv_param) {
33   ConvolutionWinogradBaseStruct *kernel = NULL;
34 
35 #ifdef ENABLE_AVX
36   kernel = CreateConvWinogradAVX(conv_param);
37   if (kernel != NULL) {
38     return kernel;
39   }
40 #endif
41 
42 #ifdef ENABLE_SSE
43   kernel = CreateConvWinogradSSE(conv_param);
44   if (kernel != NULL) {
45     return kernel;
46   }
47 #endif
48 
49 #ifdef ENABLE_ARM64
50   kernel = CreateConvWinogradARM64(conv_param);
51   if (kernel != NULL) {
52     return kernel;
53   }
54 #endif
55 
56 #ifdef ENABLE_ARM32
57   kernel = CreateConvWinogradARM32(conv_param);
58   if (kernel != NULL) {
59     return kernel;
60   }
61 #endif
62 
63   kernel = CreateConvWinogradBase(conv_param);
64   return kernel;
65 }
66 
CreateConvolutionWinograd(ConvParameter * conv_param,int out_unit)67 ConvolutionBaseStruct *CreateConvolutionWinograd(ConvParameter *conv_param, int out_unit) {
68   ConvolutionWinogradBaseStruct *kernel = SelectConvolutionWinograd(conv_param);
69   NNACL_MALLOC_CHECK_NULL_RETURN_NULL(kernel);
70 
71   kernel->output_unit_ = out_unit;
72   kernel->conv_.malloc_weight_bias_ = ConvWinoBaseMallocWeightBiasData;
73   kernel->conv_.run_impl_ = ConvWinoBaseRunImpl;
74   kernel->conv_.pack_weight_ = ConvWinoBasePackWeight;
75   return (ConvolutionBaseStruct *)kernel;
76 }
77