conv_depthwise.h 14.4 KB
Newer Older
Y
Yan Chunwei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <cmath>
#include <vector>
#include "lite/core/context.h"
#include "lite/core/target_wrapper.h"
21
#include "lite/operators/op_params.h"
Y
Yan Chunwei 已提交
22 23 24 25 26 27

namespace paddle {
namespace lite {
namespace arm {
namespace math {

28
void conv_3x3s1_depthwise_fp32(const float* i_data,
Y
Yan Chunwei 已提交
29 30 31 32 33 34 35
                               float* o_data,
                               int bs,
                               int oc,
                               int oh,
                               int ow,
                               int ic,
                               int ih,
36 37 38
                               int win,
                               const float* weights,
                               const float* bias,
Y
Yan Chunwei 已提交
39
                               const operators::ConvParam& param,
40
                               const operators::ActivationParam act_param,
41
                               ARMContext* ctx);
Y
Yan Chunwei 已提交
42

43 44 45 46 47 48 49 50 51 52 53 54
void conv_3x3s2_depthwise_fp32(const float* i_data,
                               float* o_data,
                               int bs,
                               int oc,
                               int oh,
                               int ow,
                               int ic,
                               int ih,
                               int win,
                               const float* weights,
                               const float* bias,
                               const operators::ConvParam& param,
55
                               const operators::ActivationParam act_param,
56
                               ARMContext* ctx);
Y
Yan Chunwei 已提交
57

H
HappyAngel 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70
void conv_depthwise_3x3s1_fp32(const float* din,
                               float* dout,
                               int num,
                               int ch_out,
                               int h_out,
                               int w_out,
                               int ch_in,
                               int h_in,
                               int w_in,
                               const float* weights,
                               const float* bias,
                               int pad,
                               bool flag_bias,
71
                               const operators::ActivationParam act_param,
H
HappyAngel 已提交
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
                               ARMContext* ctx);

void conv_depthwise_3x3s2_fp32(const float* din,
                               float* dout,
                               int num,
                               int ch_out,
                               int h_out,
                               int w_out,
                               int ch_in,
                               int h_in,
                               int w_in,
                               const float* weights,
                               const float* bias,
                               int pad,
                               bool flag_bias,
87
                               const operators::ActivationParam act_param,
H
HappyAngel 已提交
88 89
                               ARMContext* ctx);

90 91 92 93 94 95 96
template <typename Dtype>
void conv_depthwise_3x3s1_int8(Dtype* dout,
                               const int8_t* din,
                               const int8_t* weights,
                               const float* scale,
                               const float* bias,
                               bool flag_bias,
97 98
                               int flag_act,
                               float* alpha,
99 100 101 102 103 104 105 106 107
                               int num,
                               int chin,
                               int hin,
                               int win,
                               int hout,
                               int wout,
                               int padw,
                               int padh,
                               ARMContext* ctx);
Y
Yan Chunwei 已提交
108

109 110 111 112 113 114 115
template <typename Dtype>
void conv_depthwise_3x3s2_int8(Dtype* dout,
                               const int8_t* din,
                               const int8_t* weights,
                               const float* scale,
                               const float* bias,
                               bool flag_bias,
116 117
                               int flag_act,
                               float* alpha,
118 119 120 121 122 123 124 125 126
                               int num,
                               int chin,
                               int hin,
                               int win,
                               int hout,
                               int wout,
                               int padw,
                               int padh,
                               ARMContext* ctx);
Y
Yan Chunwei 已提交
127

128 129
void conv_depthwise_5x5s1_fp32(float* dout,
                               const float* din,
130 131 132 133
                               const float* weights,
                               const float* bias,
                               bool flag_bias,
                               bool flag_relu,
134 135 136 137 138 139 140 141 142
                               int num,
                               int chin,
                               int hin,
                               int win,
                               int hout,
                               int wout,
                               int padw,
                               int padh,
                               const operators::ConvParam& param,
143
                               ARMContext* ctx);
Y
Yan Chunwei 已提交
144

145 146 147 148 149 150 151 152 153 154 155
void conv_depthwise_5x5s2_fp32(const float* din,
                               float* dout,
                               int num,
                               int chout,
                               int hout,
                               int wout,
                               int chin,
                               int hin,
                               int win,
                               const float* weights,
                               const float* bias,
156 157
                               const operators::ConvParam& param,
                               const operators::ActivationParam act_param,
158
                               ARMContext* ctx);
Y
Yan Chunwei 已提交
159

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
void conv_depthwise_5x5s2p2_fp32(const float* din,
                                 float* dout,
                                 int num,
                                 int chout,
                                 int hout,
                                 int wout,
                                 int chin,
                                 int hin,
                                 int win,
                                 const float* weights,
                                 const float* bias,
                                 int pad,
                                 bool flag_bias,
                                 bool flag_relu,
                                 ARMContext* ctx);

Y
yiicy 已提交
176 177 178 179 180 181 182
template <typename Dtype>
void conv_depthwise_5x5s1_int8(Dtype* dout,
                               const int8_t* din,
                               const int8_t* weights,
                               const float* scale,
                               const float* bias,
                               bool flag_bias,
183 184
                               int flag_act,
                               float* alpha,
Y
yiicy 已提交
185 186 187 188 189 190 191 192 193 194
                               int num,
                               int chin,
                               int hin,
                               int win,
                               int hout,
                               int wout,
                               int padw,
                               int padh,
                               ARMContext* ctx);

195 196 197 198 199 200 201
template <typename Dtype>
void conv_depthwise_5x5s2_int8(Dtype* dout,
                               const int8_t* din,
                               const int8_t* weights,
                               const float* scale,
                               const float* bias,
                               bool flag_bias,
202 203
                               int flag_act,
                               float* alpha,
204 205 206 207 208 209 210 211 212 213
                               int num,
                               int chin,
                               int hin,
                               int win,
                               int hout,
                               int wout,
                               int padw,
                               int padh,
                               ARMContext* ctx);

214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
void conv_depthwise_3x3s1p0_bias_relu(float* dout,
                                      const float* din,
                                      const float* weights,
                                      const float* bias,
                                      bool flag_bias,
                                      bool flag_relu,
                                      const int num,
                                      const int ch_in,
                                      const int h_in,
                                      const int w_in,
                                      const int h_out,
                                      const int w_out,
                                      ARMContext* ctx);

void conv_depthwise_3x3s1p0_bias_s_relu(float* dout,
                                        const float* din,
                                        const float* weights,
                                        const float* bias,
                                        bool flag_bias,
                                        bool flag_relu,
                                        const int num,
                                        const int ch_in,
                                        const int h_in,
                                        const int w_in,
                                        const int h_out,
                                        const int w_out,
                                        ARMContext* ctx);

void conv_depthwise_3x3s1p1_bias_relu(float* dout,
                                      const float* din,
                                      const float* weights,
                                      const float* bias,
                                      bool flag_bias,
                                      bool flag_relu,
                                      const int num,
                                      const int ch_in,
                                      const int h_in,
                                      const int w_in,
                                      const int h_out,
                                      const int w_out,
                                      ARMContext* ctx);

void conv_depthwise_3x3s1p1_bias_s_relu(float* dout,
                                        const float* din,
                                        const float* weights,
                                        const float* bias,
                                        bool flag_bias,
                                        bool flag_relu,
                                        const int num,
                                        const int ch_in,
                                        const int h_in,
                                        const int w_in,
                                        const int h_out,
                                        const int w_out,
                                        ARMContext* ctx);

void conv_depthwise_3x3s2p0_bias_relu(float* dout,
                                      const float* din,
                                      const float* weights,
                                      const float* bias,
                                      bool flag_bias,
                                      bool flag_relu,
                                      const int num,
                                      const int ch_in,
                                      const int h_in,
                                      const int w_in,
                                      const int h_out,
                                      const int w_out,
                                      ARMContext* ctx);

void conv_depthwise_3x3s2p0_bias_s_relu(float* dout,
                                        const float* din,
                                        const float* weights,
                                        const float* bias,
                                        bool flag_bias,
                                        bool flag_relu,
                                        const int num,
                                        const int ch_in,
                                        const int h_in,
                                        const int w_in,
                                        const int h_out,
                                        const int w_out,
                                        ARMContext* ctx);

void conv_depthwise_3x3s2p1_bias_relu(float* dout,
                                      const float* din,
                                      const float* weights,
                                      const float* bias,
                                      bool flag_bias,
                                      bool flag_relu,
                                      const int num,
                                      const int ch_in,
                                      const int h_in,
                                      const int w_in,
                                      const int h_out,
                                      const int w_out,
                                      ARMContext* ctx);

void conv_depthwise_3x3s2p1_bias_s_relu(float* dout,
                                        const float* din,
                                        const float* weights,
                                        const float* bias,
                                        bool flag_bias,
                                        bool flag_relu,
                                        const int num,
                                        const int ch_in,
                                        const int h_in,
                                        const int w_in,
                                        const int h_out,
                                        const int w_out,
                                        ARMContext* ctx);

Y
Yan Chunwei 已提交
326 327 328 329
}  // namespace math
}  // namespace arm
}  // namespace lite
}  // namespace paddle