/usr/local/lib64/python3.6/site-packages/torch/include/caffe2/core
NameSizeModeActions
allocator.h1360644editdlrm
blob.h41680644editdlrm
blob_serialization.h107910644editdlrm
blob_serializer_base.h39050644editdlrm
blob_stats.h11270644editdlrm
common.h43290644editdlrm
common_cudnn.h98930644editdlrm
common_gpu.h214140644editdlrm
common_omp.h1560644editdlrm
context.h61740644editdlrm
context_base.h43820644editdlrm
context_gpu.h110140644editdlrm
cudnn_wrappers.h69560644editdlrm
db.h93520644editdlrm
distributions_stubs.h21610644editdlrm
event.h124200644editdlrm
event_cpu.h11920644editdlrm
export_c10_op_to_caffe2.h94870644editdlrm
export_caffe2_op_to_c10.h111010644editdlrm
flags.h740644editdlrm
graph.h52580644editdlrm
init.h64960644editdlrm
logging.h750644editdlrm
macros.h34260644editdlrm
memonger.h8170644editdlrm
module.h24730644editdlrm
net.h46340644editdlrm
net_async_base.h73970644editdlrm
net_async_scheduling.h9930644editdlrm
net_async_task.h8330644editdlrm
net_async_task_future.h19250644editdlrm
net_async_task_graph.h22530644editdlrm
net_async_tracing.h50930644editdlrm
net_dag_utils.h21460644editdlrm
net_parallel.h21440644editdlrm
net_simple.h26060644editdlrm
net_simple_refcount.h20970644editdlrm
numa.h720644editdlrm
observer.h38090644editdlrm
operator.h588720644editdlrm
operator_gradient.h102220644editdlrm
operator_schema.h184770644editdlrm
plan_executor.h2190644editdlrm
prof_dag_counters.h27510644editdlrm
qtensor.h66150644editdlrm
qtensor_serialization.h26240644editdlrm
scope_guard.h46750644editdlrm
static_tracepoint.h3980644editdlrm
static_tracepoint_elfx86.h55550644editdlrm
stats.h103650644editdlrm
storage.h7330644editdlrm
tensor.h186680644editdlrm
tensor_impl.h3510644editdlrm
tensor_int8.h4500644editdlrm
test_utils.h62850644editdlrm
timer.h12180644editdlrm
transform.h57410644editdlrm
types.h22480644editdlrm
workspace.h113050644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/caffe2/core/graph.h (5258B)
#pragma once #include "caffe2/core/common.h" #include "caffe2/proto/caffe2_pb.h" #include "caffe2/utils/proto_utils.h" #include "caffe2/utils/string_utils.h" #include #include #include namespace caffe2 { namespace transform { /** * Graph representation of an operator. */ struct TORCH_API Node { public: // Empty constructor for resize Node() {} // Alternate constructor Node( const OperatorDef& op, bool active, std::map> parents, std::map> children) : op(op), active(active), parents(parents), children(children) {} // The OperatorDef which this node represents. OperatorDef op; // Keeps track of if an operator has been deleted through a transformation. bool active = true; // Stores a pair (idx, blob_list), // idx = index of the child // blob_list = a list of strings, containing the blobs that connect the nodes std::map> parents; std::map> children; }; /** * Graph representation of a Netdef. */ struct TORCH_API Graph { public: /** * Given a subgraph, gets all of the parents of the subgraph, as well as * their associated blob names. Sorted by blob names. * * := (name of blob writing into subgraph, * index of node that writes into subgraph using that blob) */ const std::vector> GetSubgraphInput( const std::vector& subgraph); /** * Given a subgraph, gets all of the children of the subgraph, as well as * their associated blob names. Sorted by blob names. * * := (name of blob reading from subgraph, * index of node that reads from subgraph using that blob) */ const std::vector> GetSubgraphOutput( const std::vector& subgraph); /** * Graph generation. * Given a netdef, returns a Graph. * * Each node represents an operator. * An edge exists between two nodes if the parent op writes to a blob, which * is the input of the child blob, with no other op writing to the blob in * between the execution order. * * Time Complexity: O(E), where E is the number of blobs */ explicit Graph(const NetDef& net_def); /** * Generates a NetDef Representation for the current graph. * Nodes are visited in topological order, which is proper Opdef ordering. * TODO(benz): * There exists conflicts with repeated blob names, where topological sorting * is not sufficient for correct netdef representation, unless blobs are * renamed. * For example, if after a transformation, We have operator ancestry: * A --> B --> C, and also A --> D --> E, where B -> C and D -> E uses the * same blob name, then A, B, D, E, C is a correct topological ordering, * but D will write to the blob that C reads from, instead of B. * Currently believe that there will always be ambiguity unless blobs are * renamed. * This is solved by performing SSA on all transformed blob names. */ NetDef GetNetDef(); /** * Deactivate a subgraph, and get rid of all edges into this subgraph. */ void DeactivateSubgraph(std::vector subgraph); size_t size() const { return nodes_.size(); } void push_node(const Node& new_node) { return nodes_.push_back(new_node); } void resize_nodes(size_t new_size) { nodes_.resize(new_size); } // Index safe, less verbose way to access nodes inline const Node& node(size_t idx) const { return nodes_.at(idx); } inline Node& node(size_t idx) { return nodes_.at(idx); } inline bool is_node_active(size_t idx) { return node(idx).active; } inline const std::set& external_input() const { return external_input_; } inline const std::set& external_output() const { return external_output_; } private: const std::vector> GetSubgraphPerimeterHelper( bool from_children, const std::vector& match); // Stores the netdef representation. Is updated upon calls to GetNetDef. NetDef netdef_; // Stores which blobs the graph reads from, and writes to. std::set external_input_; std::set external_output_; // Keeps track of all the Operators currently within graph, even if inactive. std::vector nodes_; }; } // namespace transform // Adds an operator def to a netdef. // Returns the ptr, if you want to add anything extra (such as device_option) TORCH_API OperatorDef* AddOp( NetDef* netdef_ptr, string op_type, std::vector inputs, std::vector outputs); /** * This allows for the use of * and | to match operator types, * engines, or any other property that is represented by strings. * * For example, if we wanted to match an operator to Conv or FC, we can give: * "Conv|FC" as the type() of that op. */ TORCH_API bool MatchStrings(string p, string s); /** * This ensures that each named arg that exists in the pattern exists in g_op, * is equal in value. */ TORCH_API bool MatchArguments(const OperatorDef& p_op, const OperatorDef& g_op); } // namespace caffe2