OpenPose  1.7.0
The first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints
arrayCpuGpu.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_CORE_ARRAY_CPU_GPU_HPP
2 #define OPENPOSE_CORE_ARRAY_CPU_GPU_HPP
3 
4 #include <memory> // std::shared_ptr
5 #include <vector>
8 
9 namespace op
10 {
14  template<typename T>
16  {
17  public:
23  explicit ArrayCpuGpu(const void* caffeBlobTPtr);
30  explicit ArrayCpuGpu(const Array<T>& array, const bool copyFromGpu);
31  explicit ArrayCpuGpu(const int num, const int channels, const int height, const int width);
32  // explicit ArrayCpuGpu(const std::vector<int>& shape);
33 
34  void Reshape(const int num, const int channels, const int height, const int width);
35  void Reshape(const std::vector<int>& shape);
36  // // void Reshape(const BlobShape& shape);
37  // // void ReshapeLike(const Blob& other);
38  // void ReshapeLike(const ArrayCpuGpu& other);
39  std::string shape_string() const;
40  const std::vector<int>& shape() const;
41  int shape(const int index) const;
42  int num_axes() const;
43  int count() const;
44  int count(const int start_axis, const int end_axis) const;
45  int count(const int start_axis) const;
46 
47  int CanonicalAxisIndex(const int axis_index) const;
48 
49  int num() const;
50  int channels() const;
51  int height() const;
52  int width() const;
53  int LegacyShape(const int index) const;
54 
55  int offset(const int n, const int c = 0, const int h = 0, const int w = 0) const;
56  // int offset(const std::vector<int>& indices) const; // Caffe warning
57 
58  // // void CopyFrom(const Blob<T>& source, bool copy_diff = false, bool reshape = false);
59  // void CopyFrom(const ArrayCpuGpu<T>& source, bool copy_diff = false, bool reshape = false);
60 
61  T data_at(const int n, const int c, const int h, const int w) const;
62  T diff_at(const int n, const int c, const int h, const int w) const;
63  // T data_at(const std::vector<int>& index) const; // Caffe warning
64  // T diff_at(const std::vector<int>& index) const; // Caffe warning
65 
66  // const boost::shared_ptr<SyncedMemory>& data() const;
67  // const boost::shared_ptr<SyncedMemory>& diff() const;
68 
69  const T* cpu_data() const;
70  void set_cpu_data(T* data);
71  const int* gpu_shape() const;
72  const T* gpu_data() const;
73  void set_gpu_data(T* data);
74  const T* cpu_diff() const;
75  const T* gpu_diff() const;
80  void Update();
81  // void FromProto(const BlobProto& proto, bool reshape = true);
82  // void ToProto(BlobProto* proto, bool write_diff = false) const;
83 
84  T asum_data() const;
85  T asum_diff() const;
86  T sumsq_data() const;
87  T sumsq_diff() const;
88 
89  void scale_data(const T scale_factor);
90  void scale_diff(const T scale_factor);
91 
92  // void ShareData(const Blob& other);
93  // void ShareDiff(const Blob& other);
94 
95  // bool ShapeEquals(const BlobProto& other);
96 
97  private:
98  // PIMPL idiom
99  // http://www.cppsamples.com/common-tasks/pimpl.html
100  struct ImplArrayCpuGpu;
101  std::shared_ptr<ImplArrayCpuGpu> spImpl;
102 
103  // PIMP requires DELETE_COPY & destructor, or extra code
104  // http://oliora.github.io/2015/12/29/pimpl-and-rule-of-zero.html
106  };
107 
108  // // Static methods
109  // OVERLOAD_C_OUT(ArrayCpuGpu)
110 }
111 
112 #endif // OPENPOSE_CORE_ARRAY_CPU_GPU_HPP
ArrayCpuGpu(const int num, const int channels, const int height, const int width)
void scale_diff(const T scale_factor)
void scale_data(const T scale_factor)
int height() const
void Reshape(const std::vector< int > &shape)
T sumsq_diff() const
const T * gpu_data() const
int channels() const
int shape(const int index) const
T diff_at(const int n, const int c, const int h, const int w) const
std::string shape_string() const
T data_at(const int n, const int c, const int h, const int w) const
void set_gpu_data(T *data)
ArrayCpuGpu(const void *caffeBlobTPtr)
int width() const
int count(const int start_axis) const
T asum_diff() const
T * mutable_gpu_diff()
T sumsq_data() const
T * mutable_cpu_data()
const int * gpu_shape() const
T asum_data() const
const T * cpu_data() const
int LegacyShape(const int index) const
void Reshape(const int num, const int channels, const int height, const int width)
const T * gpu_diff() const
int count() const
int num() const
T * mutable_cpu_diff()
T * mutable_gpu_data()
const T * cpu_diff() const
int count(const int start_axis, const int end_axis) const
ArrayCpuGpu(const Array< T > &array, const bool copyFromGpu)
void set_cpu_data(T *data)
int num_axes() const
int CanonicalAxisIndex(const int axis_index) const
int offset(const int n, const int c=0, const int h=0, const int w=0) const
const std::vector< int > & shape() const
#define DELETE_COPY(className)
Definition: macros.hpp:32