• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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 MINDSPORE_NNACL_FP32_COMMON_FUNC_H_
18 #define MINDSPORE_NNACL_FP32_COMMON_FUNC_H_
19 
20 #include <string.h>
21 #include "nnacl/op_base.h"
22 #include "nnacl/conv_parameter.h"
23 
24 typedef struct ConvDwFp32BorderParam {
25   float *dst;
26   const float *src;
27   const float *weight;
28   const float *bias;
29   size_t height;
30   size_t width;
31   size_t in_kh_step;
32   size_t in_kw_step;
33   size_t kernel_w;
34   size_t relu;
35   size_t relu6;
36 } ConvDwFp32BorderParam;
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 void PostConvFuncFp32C8(const float *c8_out_ptr, float *out_ptr, const float *bias_ptr, size_t output_channel,
43                         size_t plane_size, size_t stride, size_t relu_type);
44 void PostConvFuncFp32C4(const float *c4_out_ptr, float *out_ptr, const float *bias_ptr, size_t output_channel,
45                         size_t plane_size, size_t plane_stride, size_t relu_type);
46 
47 void WinogradTransLeft(const float *S, const float *B, float *M, size_t w, size_t h, size_t k, size_t length);
48 void WinogradTransRight(const float *S, const float *B, float *M, size_t w, size_t h, size_t k, size_t length);
49 
50 #if defined(ENABLE_ARM) || defined(ENABLE_SSE)
51 void ConvDwFp32Center(float *dst, const float *src, const float *weight, const float *bias, size_t height, size_t width,
52                       size_t kernel_h, size_t kernel_w, size_t out_h_step, size_t block_channel, size_t in_sh_step,
53                       size_t in_sw_step, size_t in_kh_step, size_t in_kw_step, size_t relu, size_t relu6);
54 #ifdef ENABLE_AVX
55 void ConvDwFp32Border(ConvDwFp32BorderParam *param);
56 #else
57 void ConvDwFp32Border(float *dst, const float *src, const float *weight, const float *bias, size_t height, size_t width,
58                       size_t in_kh_step, size_t in_kw_step, size_t kernel_w, size_t relu, size_t relu6);
59 #endif
60 void DeconvDwFp32Center(float *dst, const float *src, const float *weight, size_t height, size_t width, size_t kernel_h,
61                         size_t kernel_w, size_t out_h_step, size_t block_channel, size_t in_sh_step, size_t in_sw_step,
62                         size_t in_kh_step, size_t in_kw_step);
63 void PostFuncBiasReluC8(float *dst, const float *src, const float *bias, size_t oc8div, size_t oc8mod,
64                         size_t plane_size, size_t stride, size_t relu_type);
65 void ConvDwFp32Row(float *output_ptr, const float *input_ptr, const float *weight_ptr, size_t num_pixels,
66                    size_t output_channel, size_t input_step);
67 void PostFuncBiasReluC4(float *dst, const float *src, const float *bias, size_t oc4div, size_t oc4mod,
68                         size_t plane_size, size_t plane_stride, size_t relu_type);
69 #endif
70 
71 #ifdef ENABLE_ARM64
72 void DeconvDwFp32Border(float *dst, const float *src, const float *weight, size_t height, size_t width,
73                         size_t in_kh_step, size_t in_kw_step, size_t kernel_w);
74 
75 void ConvSwFp32Center(float *dst, const float *src, const float *weight, const float *bias, size_t height, size_t width,
76                       size_t kernel_h, size_t kernel_w, size_t out_h_step, size_t block_channel, size_t ic4,
77                       size_t in_sh_step, size_t in_sw_step, size_t in_kh_step, size_t in_kw_step, size_t relu,
78                       size_t relu6);
79 
80 void ConvDw3x3Stride1(float *output, const float *buffer, const float *weight, const float *bias, int col_size,
81                       int row_size, int channel, int output_h, int output_w, size_t relu, size_t relu6);
82 
83 void ConvDw3x3Stride2(float *output, const float *buffer, const float *weight, const float *bias, int col_size,
84                       int row_size, int channel, int output_h, int output_w, size_t relu, size_t relu6);
85 
86 void ConvDw3x3Corner(float *dst, const float *src, const float *weight, const float *bias, int in_kh_step,
87                      int in_kw_step, int channel, size_t relu, size_t relu6);
88 
89 void ConvDw3x3Vertical(float *dst, const float *src, const float *weight, const float *bias, int in_kh_step,
90                        int in_kw_step, int channel, size_t relu, size_t relu6);
91 
92 void ConvDw3x3Horizontal(float *dst, const float *src, const float *weight, const float *bias, int in_kh_step,
93                          int in_kw_step, int channel, size_t relu, size_t relu6);
94 #endif
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 #endif /* MINDSPORE_NNACL_FP32_COMMON_FUNC_H_ */
100