fusion_group_pass.h 1.3 KB
Newer Older
1
/* Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
2 3 4 5 6 7 8 9 10 11 12 13

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. */
14

15
#pragma once
16

17
#include <string>
18
#include <unordered_set>
19
#include "paddle/fluid/framework/ir/fuse_pass_base.h"
20
#include "paddle/fluid/framework/ir/fusion_group/subgraph.h"
21 22 23 24 25

namespace paddle {
namespace framework {
namespace ir {

26
class FusionGroupPass : public FusePassBase {
27 28
 protected:
  void ApplyImpl(Graph* graph) const override;
29 30

 private:
31
  int DetectFusionGroup(Graph* graph, int type = 0) const;
32
  void GenerateCode(fusion_group::SubGraph* subgraph) const;
33
  void InsertFusionGroupOp(Graph* graph,
34
                           fusion_group::SubGraph* subgraph) const;
35 36

  const std::string name_scope_{"fusion_group"};
37
};
38

39 40 41
}  // namespace ir
}  // namespace framework
}  // namespace paddle