OpenPose  1.0.0rc2
OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
resizeAndMergeCaffe.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_NET_RESIZE_AND_MERGE_CAFFE_HPP
2 #define OPENPOSE_NET_RESIZE_AND_MERGE_CAFFE_HPP
3 
5 
6 // PIMPL does not work here. Alternative:
7 // stackoverflow.com/questions/13978775/how-to-avoid-include-dependency-to-external-library?answertab=active#tab-top
8 namespace caffe
9 {
10  template <typename T> class Blob;
11 }
12 
13 namespace op
14 {
15  // It mostly follows the Caffe::layer implementation, so Caffe users can easily use it. However, in order to keep
16  // the compatibility with any generic Caffe version, we keep this 'layer' inside our library rather than in the
17  // Caffe code.
18  template <typename T>
20  {
21  public:
22  explicit ResizeAndMergeCaffe();
23 
24  virtual ~ResizeAndMergeCaffe();
25 
26  virtual void LayerSetUp(const std::vector<caffe::Blob<T>*>& bottom, const std::vector<caffe::Blob<T>*>& top);
27 
28  virtual void Reshape(const std::vector<caffe::Blob<T>*>& bottom, const std::vector<caffe::Blob<T>*>& top,
29  const T netFactor, const T scaleFactor, const bool mergeFirstDimension = true,
30  const int gpuID = 0);
31 
32  virtual inline const char* type() const { return "ResizeAndMerge"; }
33 
34  void setScaleRatios(const std::vector<T>& scaleRatios);
35 
36  virtual void Forward_cpu(const std::vector<caffe::Blob<T>*>& bottom, const std::vector<caffe::Blob<T>*>& top);
37 
38  virtual void Forward_gpu(const std::vector<caffe::Blob<T>*>& bottom, const std::vector<caffe::Blob<T>*>& top);
39 
40  virtual void Forward_ocl(const std::vector<caffe::Blob<T>*>& bottom, const std::vector<caffe::Blob<T>*>& top);
41 
42  virtual void Backward_cpu(const std::vector<caffe::Blob<T>*>& top, const std::vector<bool>& propagate_down,
43  const std::vector<caffe::Blob<T>*>& bottom);
44 
45  virtual void Backward_gpu(const std::vector<caffe::Blob<T>*>& top, const std::vector<bool>& propagate_down,
46  const std::vector<caffe::Blob<T>*>& bottom);
47 
48  private:
49  std::vector<T*> mTempGPUData;
50  std::vector<T> mScaleRatios;
51  std::vector<std::array<int, 4>> mBottomSizes;
52  std::array<int, 4> mTopSize;
53  int mGpuID;
54 
56  };
57 }
58 
59 #endif // OPENPOSE_NET_RESIZE_AND_MERGE_CAFFE_HPP
#define DELETE_COPY(className)
Definition: macros.hpp:33
Definition: resizeAndMergeCaffe.hpp:19
virtual const char * type() const
Definition: resizeAndMergeCaffe.hpp:32
Definition: macros.hpp:80
std::vector< T, Alloc > vector
Definition: cl2.hpp:567
#define OP_API
Definition: macros.hpp:18