• 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 NNACL_CONV_PARAMETER_H_
18 #define NNACL_CONV_PARAMETER_H_
19 
20 #include "nnacl/op_base.h"
21 #include "nnacl/int8/quantize.h"
22 
23 typedef struct ConvParameter {
24   OpParameter op_parameter_;
25   ConvQuantArg conv_quant_arg_;
26 
27   int kernel_h_;
28   int kernel_w_;
29   int stride_h_;
30   int stride_w_;
31   int dilation_h_;
32   int dilation_w_;
33   int pad_u_;
34   int pad_d_;
35   int pad_l_;
36   int pad_r_;
37   int group_;
38   int tile_num_;    /* # */
39   int input_batch_; /* # */
40   int input_h_;     /* # */
41   int input_w_;     /* # */
42   int input_channel_;
43   int output_batch_; /* # */
44   int output_h_;     /* # */
45   int output_w_;     /* # */
46   int output_channel_;
47   int thread_num_;  /* # */
48   int input_unit_;  /* # */
49   int output_unit_; /* # */
50   PadType pad_mode_;
51   ActType act_type_;
52   int channel_multiplie_; /* # */
53   int output_padding_w_;  /* # */
54   int output_padding_h_;  /* # */
55   int out_format_;
56 
57   bool dynamic_shape_;
58 } ConvParameter;
59 
60 typedef struct ConvComputeParam {
61   int kernel_h_;
62   int kernel_w_;
63   int stride_h_;
64   int stride_w_;
65   int dilation_h_;
66   int dilation_w_;
67   int pad_u_;
68   int pad_d_;
69   int pad_l_;
70   int pad_r_;
71 
72   int in_n_;
73   int in_h_;
74   int in_w_;
75   int in_c_;
76   int out_n_;
77   int out_h_;
78   int out_w_;
79   int out_c_;
80 
81   int in_hw_;
82   int out_hw_;
83   int kernel_hw_;
84   int tile_num_;
85 } ConvComputeParam;
86 
87 typedef struct SlidingWindowParam {
88   int left_;
89   int right_;
90   int top_;
91   int bottom_;
92   int c_block_;
93   int block_channel_;
94   int ic_align_;
95   int out_step_;
96   int out_h_step_;
97   int out_c_step_;
98   int out_w_step_;
99   int out_block_step_;
100   int in_step_;
101   int in_h_step_;
102   int in_sh_step_;  // stride H
103   int in_sw_step_;  // stride W
104   int in_kh_step_;  // kernel H
105   int in_kw_step_;  // kernel W
106   int kernel_step_;
107 } SlidingWindowParam;
108 
109 typedef struct ConvDwCalcParam {
110   void *num_pixels_;
111   void *out_w_start_;
112   void *out_w_end_;
113   int first_calc_kw_;
114 } ConvDwCalcParam;
115 
116 #define OUPUT_UNIT 2
117 #define DECONV_WINOGRAD_DEFAULT_UNIT 3 /* # */
118 #define DECONV_WINOGRAD_DEFAULT_TILE 8 /* # */
119 #define DECONV_WINOGRAD_BUFFER_COUNT 8 /* # */
120 typedef struct DeConvWg {              /* # */
121   void *b_buffer_;
122   void *AT_;
123   void *BT_;
124 
125   int kh_;
126   int kw_;
127 
128   int k_;
129   int i_;
130   int o_;
131 } DeConvWg;
132 
133 typedef struct DeConvWgABuffer { /* # */
134   bool buf_init_;
135   void *middle_buffer_;
136   void *dest_buffer_;
137 } DeConvWgABuffer;
138 
139 typedef struct DeConvComputeUnit { /* # */
140   void *weight_;
141   void *tmp_buffer_;
142   int w_start_;
143   int h_start_;
144   int w_size_;
145   int h_size_;
146   bool use_winograd_;
147   DeConvWg winograd_;
148 } DeConvComputeUnit;
149 
150 typedef struct DeConvParam { /* # */
151   DeConvComputeUnit *compute_units_;
152   int compute_size_;
153   DeConvWgABuffer a_buffer_[DECONV_WINOGRAD_BUFFER_COUNT];
154   int input_plane_;
155   int output_plane_;
156   int kernel_plane_;
157   int ic_div_;
158   int oc_div_;
159   int ic_up_;
160   int oc_up_;
161   int thread_num_;
162   int in_tile_count_;
163   int in_tile_h_count_;
164   int in_tile_w_count_;
165   int out_tile_h_;
166   int out_tile_w_;
167 } DeConvParam;
168 
169 #endif  // NNACL_CONV_PARAMETER_H_
170