]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - jacinto-ai/caffe-jacinto.git/blob - src/caffeine/blob.hpp
first try
[jacinto-ai/caffe-jacinto.git] / src / caffeine / blob.hpp
1 #ifndef CAFFEINE_BLOB_HPP
2 #define CAFFEINE_BLOB_HPP
4 #include <memory>
6 #include "caffeine/common.hpp"
7 #include "caffeine/syncedmem.hpp"
9 namespace caffeine {
11 template <typename Dtype>
12 class Blob {
13  public:
14   Blob()
15        : num_(0), channels_(0), height_(0), width_(0), count_(0), data_(),
16        diff_() {};
17   explicit Blob(const int num, const int channels, const int height,
18       const int width) {
19     Reshape(num, channels, height, width);
20   };
21   ~Blob() {};
22   void Reshape(const int num, const int channels, const int height,
23                const int width);
24   inline int num() { return num_; }
25   inline int channels() { return channels_; }
26   inline int height() { return height_; }
27   inline int width() { return width_; }
28   
29   const Dtype* cpu_data();
30   const Dtype* gpu_data();
31   const Dtype* cpu_diff();
32   const Dtype* gpu_diff();
33   Dtype* mutable_cpu_data();
34   Dtype* mutable_gpu_data();
35   Dtype* mutable_cpu_diff();
36   Dtype* mutable_gpu_diff();  
37  private:
38   void check_data();
39   void check_diff();
40   shared_ptr<SyncedMemory> data_;
41   shared_ptr<SyncedMemory> diff_;
42   int num_;
43   int channels_;
44   int height_;
45   int width_;
46   int count_;
47 };  // class Blob
49 }  // namespace caffeine
51 #endif  // CAFFEINE_BLOB_HPP_