Merge pull request #868 from shelhamer/license-copyright
[platform/upstream/caffeonacl.git] / src / caffe / layers / hdf5_output_layer.cu
1 #include <vector>
2
3 #include "hdf5.h"
4 #include "hdf5_hl.h"
5
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"
11
12 namespace caffe {
13
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();
25
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]);
31   }
32   SaveBlobs();
33   return Dtype(0.);
34 }
35
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) {
39   return;
40 }
41
42 INSTANTIATE_CLASS(HDF5OutputLayer);
43
44 }  // namespace caffe