6 #include "caffe/blob.hpp"
7 #include "caffe/common.hpp"
8 #include "caffe/layer.hpp"
9 #include "caffe/util/io.hpp"
10 #include "caffe/vision_layers.hpp"
14 template <typename Dtype>
15 Dtype HDF5OutputLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
16 vector<Blob<Dtype>*>* top) {
17 CHECK_GE(bottom.size(), 2);
18 CHECK_EQ(bottom[0]->num(), bottom[1]->num());
19 data_blob_.Reshape(bottom[0]->num(), bottom[0]->channels(),
20 bottom[0]->height(), bottom[0]->width());
21 label_blob_.Reshape(bottom[1]->num(), bottom[1]->channels(),
22 bottom[1]->height(), bottom[1]->width());
23 const int data_datum_dim = bottom[0]->count() / bottom[0]->num();
24 const int label_datum_dim = bottom[1]->count() / bottom[1]->num();
26 for (int i = 0; i < bottom[0]->num(); ++i) {
27 caffe_copy(data_datum_dim, &bottom[0]->gpu_data()[i * data_datum_dim],
28 &data_blob_.mutable_cpu_data()[i * data_datum_dim]);
29 caffe_copy(label_datum_dim, &bottom[1]->gpu_data()[i * label_datum_dim],
30 &label_blob_.mutable_cpu_data()[i * label_datum_dim]);
36 template <typename Dtype>
37 void HDF5OutputLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
38 const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom) {
42 INSTANTIATE_CLASS(HDF5OutputLayer);