Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Member Functions
caffe2::transform::Graph Struct Reference

Graph representation of a Netdef. More...

#include <graph.h>

Public Member Functions

const std::vector< std::pair< string, int > > GetSubgraphInput (const std::vector< int > &subgraph)
 Given a subgraph, gets all of the parents of the subgraph, as well as their associated blob names. More...
 
const std::vector< std::pair< string, int > > GetSubgraphOutput (const std::vector< int > &subgraph)
 Given a subgraph, gets all of the children of the subgraph, as well as their associated blob names. More...
 
 Graph (const NetDef &net_def)
 Graph generation. More...
 
NetDef GetNetDef ()
 Generates a NetDef Representation for the current graph. More...
 
void DeactivateSubgraph (std::vector< int > subgraph)
 Deactivate a subgraph, and get rid of all edges into this subgraph.
 
const size_t size () const
 
void push_node (const Node &new_node)
 
void resize_nodes (size_t new_size)
 
const Nodenode (size_t idx) const
 
Nodenode (size_t idx)
 
bool is_node_active (size_t idx)
 
const std::set< string > & external_input () const
 
const std::set< string > & external_output () const
 

Detailed Description

Graph representation of a Netdef.

Definition at line 64 of file graph.h.

Constructor & Destructor Documentation

caffe2::transform::Graph::Graph ( const NetDef &  net_def)
explicit

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

Definition at line 28 of file graph.cc.

Member Function Documentation

NetDef caffe2::transform::Graph::GetNetDef ( )

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.

Definition at line 117 of file graph.cc.

const std::vector< std::pair< string, int > > caffe2::transform::Graph::GetSubgraphInput ( const std::vector< int > &  subgraph)

Given a subgraph, gets all of the parents of the subgraph, as well as their associated blob names.

Sorted by blob names.

<string, int> := (name of blob writing into subgraph, index of node that writes into subgraph using that blob)

Definition at line 75 of file graph.cc.

const std::vector< std::pair< string, int > > caffe2::transform::Graph::GetSubgraphOutput ( const std::vector< int > &  subgraph)

Given a subgraph, gets all of the children of the subgraph, as well as their associated blob names.

Sorted by blob names.

<string, int> := (name of blob reading from subgraph, index of node that reads from subgraph using that blob)

Definition at line 80 of file graph.cc.


The documentation for this struct was generated from the following files: