depthwise_conv_arm_func.h 1.8 KB
Newer Older
L
liuruilong 已提交
1
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
L
liuruilong 已提交
2

L
liuruilong 已提交
3 4 5
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
L
liuruilong 已提交
6

L
liuruilong 已提交
7 8 9 10 11 12 13 14
    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. */

15
#ifdef DEPTHWISECONV_OP
L
liuruilong 已提交
16 17

#pragma once
E
eclipsess 已提交
18
#include <operators/math/depthwise_conv_3x3.h>
19
#include <vector>
E
eclipsess 已提交
20
#include "operators/kernel/central-arm-func/conv_arm_func.h"
L
liuruilong 已提交
21 22 23 24 25
#include "operators/op_param.h"

namespace paddle_mobile {
namespace operators {

L
liuruilong 已提交
26
template <typename P>
27
void DepthwiseConvCompute(const ConvParam &param) {
E
eclipsess 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  Tensor Bias;
  Bias.mutable_data<float>({param.Groups()});
  if (param.Groups() == param.Input()->dims()[1] &&
      param.Filter()->dims()[2] == param.Filter()->dims()[3] &&
      param.Filter()->dims()[2] == 3 && param.Strides()[0] == 1) {
    math::DepthwiseConv3x3s1p1(param.Input(), param.Filter(), param.Output(),
                               &Bias, false);
  } else if (param.Groups() == param.Input()->dims()[1] &&
             param.Input()->dims()[1] == param.Output()->dims()[1] &&
             param.Filter()->dims()[2] == param.Filter()->dims()[3] &&
             param.Filter()->dims()[2] == 3 && param.Strides()[0] == 2) {
    math::DepthwiseConv3x3(param.Input(), param.Strides(), param.Paddings(),
                           param.Filter(), &Bias, param.Output(), false);
  } else {
    ConvBasic(param);
L
liuruilong 已提交
43 44 45
  }
}

L
liuruilong 已提交
46 47
}  // namespace operators
}  // namespace paddle_mobile
L
liuruilong 已提交
48 49

#endif