Caffe2 - C++ API
A deep learning, cross platform ML framework
single_op_transform.cc
1 
17 #include "caffe2/transforms/single_op_transform.h"
18 
19 #include "caffe2/core/common.h"
20 #include "caffe2/core/logging.h"
21 #include "caffe2/core/net.h"
22 #include "caffe2/proto/caffe2.pb.h"
23 
24 namespace caffe2 {
25 
26 using transform::Graph;
27 
29  const Graph& g,
30  const std::vector<int>& subgraph,
31  int idx) {
32  if (subgraph.size() == 0) {
33  return MatchOperator(g.node(idx).op);
34  }
35  return false;
36 }
37 
39  const Graph& g,
40  const std::vector<int>& subgraph) {
41  if (subgraph.size() == 1) {
42  return true;
43  }
44  return false;
45 }
46 
48  const std::vector<int>& subgraph,
49  Graph* g_ptr) {
50  CHECK(g_ptr);
51  auto& g = *g_ptr;
52  ReplaceOperator(&(g.node(subgraph[0]).op));
53  return true;
54 }
55 
56 } // 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...
bool ValidatorRule(const transform::Graph &g, const std::vector< int > &subgraph) override
The ValidatorRule essentially answers: Given a subgraph, can we accept it?
Copyright (c) 2016-present, Facebook, Inc.
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...