Caffe2 - C++ API
A deep learning, cross platform ML framework
single_op_transform.h
1 
17 #pragma once
18 
19 #include "caffe2/core/common.h"
20 #include "caffe2/core/transform.h"
21 #include "caffe2/proto/caffe2.pb.h"
22 #include "caffe2/utils/proto_utils.h"
23 
24 namespace caffe2 {
25 
34 class SingleOpTransform : public Transform {
35  protected:
36  bool PatternRule(
37  const transform::Graph& g,
38  const std::vector<int>& subgraph,
39  int idx) override;
40  bool ValidatorRule(
41  const transform::Graph& g,
42  const std::vector<int>& subgraph) override;
43  bool ReplaceRule(const std::vector<int>& subgraph, transform::Graph* g_ptr)
44  override;
45 
46  // Specify what the op needs to be to match the pattern.
47  virtual bool MatchOperator(const OperatorDef& op) = 0;
48 
49  // Specify how the operator should be replaced.
50  virtual void ReplaceOperator(OperatorDef* op) = 0;
51 };
52 
53 } // 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?
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...
Single Op Transform Base class.