inline Dtype Layer<Dtype>::Forward(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
Dtype loss = 0;
+ Reshape(bottom, top);
switch (Caffe::mode()) {
case Caffe::CPU:
Forward_cpu(bottom, top);
}
for (int i = start; i <= end; ++i) {
// LOG(ERROR) << "Forwarding " << layer_names_[i];
- layers_[i]->Reshape(bottom_vecs_[i], top_vecs_[i]);
Dtype layer_loss = layers_[i]->Forward(bottom_vecs_[i], top_vecs_[i]);
loss += layer_loss;
if (debug_info_) { ForwardDebugInfo(i); }
caffe_copy(ip2.blobs()[0]->count(), ip.blobs()[0]->cpu_data(),
ip2.blobs()[0]->mutable_cpu_data());
// Forward in-place
- ip.Reshape(this->blob_bottom_vec_, this->blob_top_vec_);
ip.Forward(this->blob_bottom_vec_, this->blob_top_vec_);
- prelu.Reshape(this->blob_top_vec_, this->blob_top_vec_);
prelu.Forward(this->blob_top_vec_, this->blob_top_vec_);
// Forward non-in-place
- ip2.Reshape(blob_bottom_vec_2, blob_middle_vec_2);
ip2.Forward(blob_bottom_vec_2, blob_middle_vec_2);
- prelu2.Reshape(blob_middle_vec_2, blob_top_vec_2);
prelu2.Forward(blob_middle_vec_2, blob_top_vec_2);
// Check numbers
for (int s = 0; s < blob_top_2->count(); ++s) {
forward_timer.Start();
for (int i = 0; i < layers.size(); ++i) {
timer.Start();
- // Although Reshape should be essentially free, we include it here
- // so that we will notice Reshape performance bugs.
- layers[i]->Reshape(bottom_vecs[i], top_vecs[i]);
layers[i]->Forward(bottom_vecs[i], top_vecs[i]);
forward_time_per_layer[i] += timer.MicroSeconds();
}