1 // Copyright 2014 BVLC and contributors.
8 #include "caffe/blob.hpp"
9 #include "caffe/common.hpp"
10 #include "caffe/layer.hpp"
11 #include "caffe/util/io.hpp"
12 #include "caffe/vision_layers.hpp"
16 template <typename Dtype>
17 Dtype HDF5OutputLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
18 vector<Blob<Dtype>*>* top) {
19 CHECK_GE(bottom.size(), 2);
20 CHECK_EQ(bottom[0]->num(), bottom[1]->num());
21 data_blob_.Reshape(bottom[0]->num(), bottom[0]->channels(),
22 bottom[0]->height(), bottom[0]->width());
23 label_blob_.Reshape(bottom[1]->num(), bottom[1]->channels(),
24 bottom[1]->height(), bottom[1]->width());
25 const int data_datum_dim = bottom[0]->count() / bottom[0]->num();
26 const int label_datum_dim = bottom[1]->count() / bottom[1]->num();
28 for (int i = 0; i < bottom[0]->num(); ++i) {
29 caffe_copy(data_datum_dim, &bottom[0]->gpu_data()[i * data_datum_dim],
30 &data_blob_.mutable_cpu_data()[i * data_datum_dim]);
31 caffe_copy(label_datum_dim, &bottom[0]->gpu_data()[i * label_datum_dim],
32 &label_blob_.mutable_cpu_data()[i * label_datum_dim]);
38 template <typename Dtype>
39 void HDF5OutputLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
40 const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom) {
44 INSTANTIATE_CLASS(HDF5OutputLayer);