conv_bias_mkldnn_fuse_pass.h 1.7 KB
Newer Older
M
Michal Gallus 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright (c) 2018 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
M
Michal Gallus 已提交
15
#include <string>
W
wanghuancoder 已提交
16

M
Michal Gallus 已提交
17 18 19 20
#include "paddle/fluid/framework/ir/fuse_pass_base.h"
#include "paddle/fluid/framework/ir/graph.h"
#include "paddle/fluid/framework/ir/graph_pattern_detector.h"
#include "paddle/fluid/framework/ir/pass.h"
W
wanghuancoder 已提交
21

M
Michal Gallus 已提交
22 23 24 25 26 27
namespace paddle {
namespace framework {
namespace ir {
/*
* Fuse the Conv and Elementwise_add to a ConvBiasOp.
*/
W
wanghuancoder 已提交
28 29
class Graph;

M
Michal Gallus 已提交
30 31
class ConvBiasFusePass : public FusePassBase {
 public:
32
  ConvBiasFusePass();
M
Michal Gallus 已提交
33
  virtual ~ConvBiasFusePass() {}
34
  virtual std::string type() const { return "conv2d"; }
M
Michal Gallus 已提交
35 36

 protected:
37
  void ApplyImpl(ir::Graph* graph) const override;
M
Michal Gallus 已提交
38
  const std::string name_scope_{"conv_bias_mkldnn_fuse"};
M
Michal Gallus 已提交
39
};
Y
Yihua Xu 已提交
40 41 42
/*
* Fuse the Conv3D and Elementwise_add to a Conv3DBiasOp.
*/
43 44
class Conv2DTransposeBiasFusePass : public ConvBiasFusePass {
 public:
45
  Conv2DTransposeBiasFusePass();
46 47 48
  std::string type() const override { return "conv2d_transpose"; }
};

Y
Yihua Xu 已提交
49 50
class Conv3DBiasFusePass : public ConvBiasFusePass {
 public:
51
  Conv3DBiasFusePass();
52
  std::string type() const override { return "conv3d"; }
Y
Yihua Xu 已提交
53
};
M
Michal Gallus 已提交
54 55 56
}  // namespace ir
}  // namespace framework
}  // namespace paddle