Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep track of the layer graph #2073

Closed
wants to merge 1 commit into from
Closed

Conversation

longjon
Copy link
Contributor

@longjon longjon commented Mar 9, 2015

Currently, Net keeps track of each layer's input and output blobs. However, since layers can be in-place, this information isn't sufficient to easily obtain the dependencies present in the computation graph.

This PR adds layer_parents and layer_children to Net. The parents of a layer (index) are the layers (indices) whose forwards must come before that layer's forward. The children of a layer are the layers whose backwards must come before that layer's backward.

Note that the hard distinction that we've maintained so far between backward and forward means that there are additional, untracked dependencies in the computation graph; namely, a layer's forward must come before its backward. I don't anticipate any serious consequences of this.

This graph will be used in a future PR, to allow correct multithreaded computation.

Instead of just keeping track of input and output blobs, also keep track
of layer dependencies. (Also adjust AppendBottom's argument types to
avoid passing an input as a pointer.)
@@ -369,17 +383,21 @@ void Net<Dtype>::AppendTop(const NetParameter& param, const int layer_id,
template <typename Dtype>
int Net<Dtype>::AppendBottom(const NetParameter& param,
const int layer_id, const int bottom_id,
set<string>* available_blobs, map<string, int>* blob_name_to_idx) {
set<string>* available_blobs, const map<string, int>& blob_name_to_idx,
const map<int, int>& top_blob_idx_to_layer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

available_blobs should be last arg

@jeffdonahue
Copy link
Contributor

LGTM other than my style comment. Ideally it'd have a test or two but I guess it can't break anything given that it's just adding some new member vars...

@futurely
Copy link

There is a very simple solution to manage the forward and backward computation of the predecessors and successors in a general flow graph.

@shelhamer
Copy link
Member

Closing as #2219 was closed.

@shelhamer shelhamer closed this Apr 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants