Caffe2 - C++ API
A deep learning, cross platform ML framework
common_subexpression_elimination.h
1 
18 #pragma once
19 
20 #include "caffe2/core/common.h"
21 #include "caffe2/core/transform.h"
22 #include "caffe2/proto/caffe2.pb.h"
23 #include "caffe2/utils/proto_utils.h"
24 
25 namespace caffe2 {
26 
45  public:
47  SetPatternMatchType(SORTED_WRT_EXECUTION_ORDER);
48  }
49 
50  protected:
51  bool PatternRule(
52  const transform::Graph& g,
53  const std::vector<int>& subgraph,
54  int idx) override;
55  bool ValidatorRule(
56  const transform::Graph& g,
57  const std::vector<int>& subgraph) override;
58  bool ReplaceRule(const std::vector<int>& subgraph, transform::Graph* g_ptr)
59  override;
60 
61  private:
62  bool IsWhitelisted(string op_type) {
63  return whitelisted_ops_.count(op_type);
64  }
65  std::set<string> whitelisted_ops_ = {"LearningRate", "FC"};
66 };
67 
68 } // namespace caffe2
bool PatternRule(const transform::Graph &g, const std::vector< int > &subgraph, int idx) override
The PatternRule essentially answers: Given the current subgraph (ordered), should we append the new n...
Graph representation of a Netdef.
Definition: graph.h:64
The Transform Base Object.
Definition: transform.h:50
bool ValidatorRule(const transform::Graph &g, const std::vector< int > &subgraph) override
The ValidatorRule essentially answers: Given a subgraph, can we accept it?
bool ReplaceRule(const std::vector< int > &subgraph, transform::Graph *g_ptr) override
The ReplaceRule actually mutates the graph, and applies the transformation upon the subgraph...
Copyright (c) 2016-present, Facebook, Inc.