MCPcopy Create free account
hub / github.com/BVLC/caffe / AppendTop

Method AppendTop

src/caffe/net.cpp:356–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354// Helper for Net::Init: add a new top blob to the net.
355template <typename Dtype>
356void Net<Dtype>::AppendTop(const NetParameter& param, const int layer_id,
357 const int top_id, set<string>* available_blobs,
358 map<string, int>* blob_name_to_idx) {
359 shared_ptr<LayerParameter> layer_param(
360 new LayerParameter(param.layer(layer_id)));
361 const string& blob_name = (layer_param->top_size() > top_id) ?
362 layer_param->top(top_id) : "(automatic)";
363 // Check if we are doing in-place computation
364 if (blob_name_to_idx && layer_param->bottom_size() > top_id &&
365 blob_name == layer_param->bottom(top_id)) {
366 // In-place computation
367 LOG_IF(INFO, Caffe::root_solver())
368 << layer_param->name() << " -> " << blob_name << " (in-place)";
369 top_vecs_[layer_id].push_back(blobs_[(*blob_name_to_idx)[blob_name]].get());
370 top_id_vecs_[layer_id].push_back((*blob_name_to_idx)[blob_name]);
371 } else if (blob_name_to_idx &&
372 blob_name_to_idx->find(blob_name) != blob_name_to_idx->end()) {
373 // If we are not doing in-place computation but have duplicated blobs,
374 // raise an error.
375 LOG(FATAL) << "Top blob '" << blob_name
376 << "' produced by multiple sources.";
377 } else {
378 // Normal output.
379 if (Caffe::root_solver()) {
380 LOG(INFO) << layer_param->name() << " -> " << blob_name;
381 }
382 shared_ptr<Blob<Dtype> > blob_pointer(new Blob<Dtype>());
383 const int blob_id = blobs_.size();
384 blobs_.push_back(blob_pointer);
385 blob_names_.push_back(blob_name);
386 blob_need_backward_.push_back(false);
387 if (blob_name_to_idx) { (*blob_name_to_idx)[blob_name] = blob_id; }
388 top_id_vecs_[layer_id].push_back(blob_id);
389 top_vecs_[layer_id].push_back(blob_pointer.get());
390 }
391 if (available_blobs) { available_blobs->insert(blob_name); }
392}
393
394// Helper for Net::Init: add a new bottom blob to the net.
395template <typename Dtype>

Callers

nothing calls this directly

Calls 3

getMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected