Caffe2 - C++ API
A deep learning, cross platform ML framework
1 #pragma once
3 #include "caffe2/core/common.h"
4 #include "caffe2/core/transform.h"
5 #include "caffe2/proto/caffe2.pb.h"
6 #include "caffe2/utils/proto_utils.h"
8 namespace caffe2 {
18 class SingleOpTransform : public Transform {
19  protected:
20  bool PatternRule(
21  const transform::Graph& g,
22  const std::vector<int>& subgraph,
23  int idx) override;
24  bool ValidatorRule(
25  const transform::Graph& g,
26  const std::vector<int>& subgraph) override;
27  bool ReplaceRule(const std::vector<int>& subgraph, transform::Graph* g_ptr)
28  override;
30  // Specify what the op needs to be to match the pattern.
31  virtual bool MatchOperator(const OperatorDef& op) = 0;
33  // Specify how the operator should be replaced.
34  virtual void ReplaceOperator(OperatorDef* op) = 0;
35 };
37 } // 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:48
The Transform Base Object.
Definition: transform.h:34
bool ValidatorRule(const transform::Graph &g, const std::vector< int > &subgraph) override
The ValidatorRule essentially answers: Given a subgraph, can we accept it?
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
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.