| 243 | |
| 244 | template <typename Dtype> |
| 245 | void RecurrentLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, |
| 246 | const vector<Blob<Dtype>*>& top) { |
| 247 | // Hacky fix for test time: reshare all the internal shared blobs, which may |
| 248 | // currently point to a stale owner blob that was dropped when Solver::Test |
| 249 | // called test_net->ShareTrainedLayersWith(net_.get()). |
| 250 | // TODO: somehow make this work non-hackily. |
| 251 | if (this->phase_ == TEST) { |
| 252 | unrolled_net_->ShareWeights(); |
| 253 | } |
| 254 | |
| 255 | DCHECK_EQ(recur_input_blobs_.size(), recur_output_blobs_.size()); |
| 256 | if (!expose_hidden_) { |
| 257 | for (int i = 0; i < recur_input_blobs_.size(); ++i) { |
| 258 | const int count = recur_input_blobs_[i]->count(); |
| 259 | DCHECK_EQ(count, recur_output_blobs_[i]->count()); |
| 260 | const Dtype* timestep_T_data = recur_output_blobs_[i]->cpu_data(); |
| 261 | Dtype* timestep_0_data = recur_input_blobs_[i]->mutable_cpu_data(); |
| 262 | caffe_copy(count, timestep_T_data, timestep_0_data); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | unrolled_net_->ForwardTo(last_layer_index_); |
| 267 | |
| 268 | if (expose_hidden_) { |
| 269 | const int top_offset = output_blobs_.size(); |
| 270 | for (int i = top_offset, j = 0; i < top.size(); ++i, ++j) { |
| 271 | top[i]->ShareData(*recur_output_blobs_[j]); |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | template <typename Dtype> |
| 277 | void RecurrentLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, |
nothing calls this directly
no test coverage detected