• 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_CONV_PARAMETER_H_
18 #define MINDSPORE_NNACL_CONV_PARAMETER_H_
19 
20 #ifdef ENABLE_NEON
21 #include <arm_neon.h>
22 #endif
23 #include "nnacl/op_base.h"
24 #include "nnacl/int8/quantize.h"
25 
26 typedef struct ConvParameter {
27   OpParameter op_parameter_;
28   ConvQuantArg conv_quant_arg_;
29   int kernel_h_;
30   int kernel_w_;
31   int stride_h_;
32   int stride_w_;
33   int dilation_h_;
34   int dilation_w_;
35   int pad_u_;
36   int pad_d_;
37   int pad_l_;
38   int pad_r_;
39   int group_;
40   int tile_num_;
41   int input_batch_;
42   int input_h_;
43   int input_w_;
44   int input_channel_;
45   int output_batch_;
46   int output_h_;
47   int output_w_;
48   int output_channel_;
49   int thread_num_;
50   int input_unit_;
51   int output_unit_;
52   PadMode pad_mode_;
53   ActType act_type_;
54   int channel_multiplie_;
55   int output_padding_w_;
56   int output_padding_h_;
57   int out_format_;
58 } ConvParameter;
59 
60 typedef struct SlidingWindowParam {
61   int left_;
62   int right_;
63   int top_;
64   int bottom_;
65   int c_block_;
66   int block_channel_;
67   int ic_align_;
68   int out_step_;
69   int out_h_step_;
70   int out_c_step_;
71   int out_w_step_;
72   int out_block_step_;
73   int in_step_;
74   int in_h_step_;
75   int in_sh_step_;  // stride H
76   int in_sw_step_;  // stride W
77   int in_kh_step_;  // kernel H
78   int in_kw_step_;  // kernel W
79   int kernel_step_;
80 } SlidingWindowParam;
81 
82 #define OUPUT_UNIT 2
83 #define DECONV_WINOGRAD_DEFAULT_UNIT 3
84 #define DECONV_WINOGRAD_DEFAULT_TILE 8
85 #define DECONV_WINOGRAD_BUFFER_COUNT 8
86 typedef struct DeConvWg {
87   void *b_buffer_;
88   void *AT_;
89   void *BT_;
90 
91   int kh_;
92   int kw_;
93 
94   int k_;
95   int i_;
96   int o_;
97 } DeConvWg;
98 
99 typedef struct DeConvWgABuffer {
100   bool buf_init_;
101   void *middle_buffer_;
102   void *dest_buffer_;
103 } DeConvWgABuffer;
104 
105 typedef struct DeConvComputeUnit {
106   void *weight_;
107   void *tmp_buffer_;
108   int w_start_;
109   int h_start_;
110   int w_size_;
111   int h_size_;
112   bool use_winograd_;
113   DeConvWg winograd_;
114 } DeConvComputeUnit;
115 
116 typedef struct DeConvParam {
117   DeConvComputeUnit *compute_units_;
118   int compute_size_;
119   DeConvWgABuffer a_buffer_[DECONV_WINOGRAD_BUFFER_COUNT];
120   int input_plane_;
121   int output_plane_;
122   int kernel_plane_;
123   int ic_div4_;
124   int oc_div4_;
125   int ic_up4_;
126   int oc_up4_;
127   int thread_num_;
128   int in_tile_count_;
129   int in_tile_h_count_;
130   int in_tile_w_count_;
131   int out_tile_h_;
132   int out_tile_w_;
133 } DeConvParam;
134 
135 #endif  // MINDSPORE_NNACL_CONV_PARAMETER_H_
136