back-merging [docs] changes and web demo [example] addition; updating
[platform/upstream/caffeonacl.git] / src / caffe / layers / hdf5_output_layer.cu
1 // Copyright 2014 BVLC and contributors.
2
3 #include <vector>
4
5 #include "hdf5.h"
6 #include "hdf5_hl.h"
7
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"
13
14 namespace caffe {
15 using std::vector;
16
17 template <typename Dtype>
18 Dtype HDF5OutputLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
19       vector<Blob<Dtype>*>* top) {
20   CHECK_GE(bottom.size(), 2);
21   CHECK_EQ(bottom[0]->num(), bottom[1]->num());
22   data_blob_.Reshape(bottom[0]->num(), bottom[0]->channels(),
23                      bottom[0]->height(), bottom[0]->width());
24   label_blob_.Reshape(bottom[1]->num(), bottom[1]->channels(),
25                      bottom[1]->height(), bottom[1]->width());
26   const int data_datum_dim = bottom[0]->count() / bottom[0]->num();
27   const int label_datum_dim = bottom[1]->count() / bottom[1]->num();
28
29   for (int i = 0; i < bottom[0]->num(); ++i) {
30     caffe_copy(data_datum_dim, &bottom[0]->gpu_data()[i * data_datum_dim],
31         &data_blob_.mutable_cpu_data()[i * data_datum_dim]);
32     caffe_copy(label_datum_dim, &bottom[0]->gpu_data()[i * label_datum_dim],
33         &label_blob_.mutable_cpu_data()[i * label_datum_dim]);
34   }
35   SaveBlobs();
36   return Dtype(0.);
37 }
38
39 template <typename Dtype>
40 void HDF5OutputLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
41       const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom) {
42   return;
43 }
44
45 INSTANTIATE_CLASS(HDF5OutputLayer);
46
47 }  // namespace caffe