#define HDF5_DATA_DATASET_NAME "data"
#define HDF5_DATA_LABEL_NAME "label"
-// This function is used to create a pthread that prefetches the data.
-template <typename Dtype>
-void* DataLayerPrefetch(void* layer_pointer);
-
-template <typename Dtype>
-class DataLayer : public Layer<Dtype> {
- // The function used to perform prefetching.
- friend void* DataLayerPrefetch<Dtype>(void* layer_pointer);
-
- public:
- explicit DataLayer(const LayerParameter& param)
- : Layer<Dtype>(param) {}
- virtual ~DataLayer();
- virtual void SetUp(const vector<Blob<Dtype>*>& bottom,
- vector<Blob<Dtype>*>* top);
-
- protected:
- virtual Dtype Forward_cpu(const vector<Blob<Dtype>*>& bottom,
- vector<Blob<Dtype>*>* top);
- virtual Dtype Forward_gpu(const vector<Blob<Dtype>*>& bottom,
- vector<Blob<Dtype>*>* top);
- virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
- const bool propagate_down, vector<Blob<Dtype>*>* bottom) { return; }
- virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
- const bool propagate_down, vector<Blob<Dtype>*>* bottom) { return; }
-
- virtual void CreatePrefetchThread();
- virtual void JoinPrefetchThread();
- virtual unsigned int PrefetchRand();
-
- shared_ptr<Caffe::RNG> prefetch_rng_;
- shared_ptr<leveldb::DB> db_;
- shared_ptr<leveldb::Iterator> iter_;
- int datum_channels_;
- int datum_height_;
- int datum_width_;
- int datum_size_;
- pthread_t thread_;
- shared_ptr<Blob<Dtype> > prefetch_data_;
- shared_ptr<Blob<Dtype> > prefetch_label_;
- Blob<Dtype> data_mean_;
- bool output_labels_;
- Caffe::Phase phase_;
-};
-
template <typename Dtype>
class HDF5OutputLayer : public Layer<Dtype> {
public:
Blob<Dtype> label_blob_;
};
+// TODO: DataLayer, ImageDataLayer, and WindowDataLayer all have the
+// same basic structure and a lot of duplicated code.
+
+// This function is used to create a pthread that prefetches the data.
+template <typename Dtype>
+void* DataLayerPrefetch(void* layer_pointer);
+
+template <typename Dtype>
+class DataLayer : public Layer<Dtype> {
+ // The function used to perform prefetching.
+ friend void* DataLayerPrefetch<Dtype>(void* layer_pointer);
+
+ public:
+ explicit DataLayer(const LayerParameter& param)
+ : Layer<Dtype>(param) {}
+ virtual ~DataLayer();
+ virtual void SetUp(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
+
+ protected:
+ virtual Dtype Forward_cpu(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
+ virtual Dtype Forward_gpu(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
+ virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
+ const bool propagate_down, vector<Blob<Dtype>*>* bottom) { return; }
+ virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
+ const bool propagate_down, vector<Blob<Dtype>*>* bottom) { return; }
+
+ virtual void CreatePrefetchThread();
+ virtual void JoinPrefetchThread();
+ virtual unsigned int PrefetchRand();
+
+ shared_ptr<Caffe::RNG> prefetch_rng_;
+ shared_ptr<leveldb::DB> db_;
+ shared_ptr<leveldb::Iterator> iter_;
+ int datum_channels_;
+ int datum_height_;
+ int datum_width_;
+ int datum_size_;
+ pthread_t thread_;
+ shared_ptr<Blob<Dtype> > prefetch_data_;
+ shared_ptr<Blob<Dtype> > prefetch_label_;
+ Blob<Dtype> data_mean_;
+ bool output_labels_;
+ Caffe::Phase phase_;
+};
+
// This function is used to create a pthread that prefetches the data.
template <typename Dtype>
void* ImageDataLayerPrefetch(void* layer_pointer);