3 #include "caffe2/core/common.h" 4 #include "caffe2/proto/caffe2_pb.h" 5 #include "caffe2/utils/proto_utils.h" 6 #include "caffe2/utils/string_utils.h" 9 #include <unordered_map> 10 #include <unordered_set> 26 const OperatorDef& op,
28 std::map<
int, std::vector<string>> parents,
29 std::map<
int, std::vector<string>> children)
30 : op(op), active(active), parents(parents), children(children) {}
41 std::map<int, std::vector<string>> parents;
42 std::map<int, std::vector<string>> children;
57 const std::vector<std::pair<string, int>> GetSubgraphInput(
58 const std::vector<int>& subgraph);
67 const std::vector<std::pair<string, int>> GetSubgraphOutput(
68 const std::vector<int>& subgraph);
81 explicit Graph(
const NetDef& net_def);
103 void DeactivateSubgraph(std::vector<int> subgraph);
105 size_t size()
const {
106 return nodes_.size();
109 void push_node(
const Node& new_node) {
110 return nodes_.push_back(new_node);
113 void resize_nodes(
size_t new_size) {
114 nodes_.resize(new_size);
118 inline const Node& node(
size_t idx)
const {
119 return nodes_.at(idx);
122 inline Node& node(
size_t idx) {
123 return nodes_.at(idx);
126 inline bool is_node_active(
size_t idx) {
127 return node(idx).active;
130 inline const std::set<string>& external_input()
const {
131 return external_input_;
134 inline const std::set<string>& external_output()
const {
135 return external_output_;
139 const std::vector<std::pair<string, int>> GetSubgraphPerimeterHelper(
141 const std::vector<int>& match);
147 std::set<string> external_input_;
148 std::set<string> external_output_;
151 std::vector<Node> nodes_;
158 CAFFE2_API OperatorDef* AddOp(
161 std::vector<string> inputs,
162 std::vector<string> outputs);
177 CAFFE2_API
bool MatchArguments(
const OperatorDef& p_op,
const OperatorDef& g_op);
bool MatchStrings(string p, string s)
This allows for the use of * and | to match operator types, engines, or any other property that is re...
bool MatchArguments(const OperatorDef &p_op, const OperatorDef &g_op)
This ensures that each named arg that exists in the pattern exists in g_op, is equal in value...
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...