Caffe2 - C++ API
A deep learning, cross platform ML framework
reduce.h
1 #ifndef CAFFE2_UTILS_MATH_REDUCE_H_
2 #define CAFFE2_UTILS_MATH_REDUCE_H_
3 
4 #include "caffe2/core/common.h"
5 #include "caffe2/core/types.h"
6 
7 namespace caffe2 {
8 
9 class Tensor;
10 
11 namespace math {
12 
13 template <typename T, class Context>
14 CAFFE2_API void
15 ReduceMin(const int N, const T* X, T* y, Tensor* scratch_ptr, Context* context);
16 
17 template <typename T, class Context>
18 CAFFE2_API void
19 ReduceMax(const int N, const T* X, T* y, Tensor* scratch_ptr, Context* context);
20 
21 // In all of the reduce functions, X_dims and Y_dims should have ndim elements.
22 // Each dimension of Y_dims must match the corresponding dimension of X_dims or
23 // must be equal to 1. The dimensions equal to 1 indicate the dimensions of X to
24 // be reduced.
25 
26 // Y = alpha * ReduceMin(X)
27 template <typename T, class Context>
28 CAFFE2_API void ReduceMin(
29  const int ndim,
30  const int* X_dims,
31  const int* Y_dims,
32  const T alpha,
33  const T* X,
34  T* Y,
35  Context* context);
36 
37 // Y = alpha * ReduceMax(X)
38 template <typename T, class Context>
39 CAFFE2_API void ReduceMax(
40  const int ndim,
41  const int* X_dims,
42  const int* Y_dims,
43  const T alpha,
44  const T* X,
45  T* Y,
46  Context* context);
47 
48 // Y = alpha * ReduceSum(X)
49 template <typename T, class Context>
50 CAFFE2_API void ReduceSum(
51  const int ndim,
52  const int* X_dims,
53  const int* Y_dims,
54  const T alpha,
55  const T* X,
56  T* Y,
57  Context* context);
58 
59 // Y = alpha * ReduceMean(X)
60 template <typename T, class Context>
61 CAFFE2_API void ReduceMean(
62  const int ndim,
63  const int* X_dims,
64  const int* Y_dims,
65  const T alpha,
66  const T* X,
67  T* Y,
68  Context* context);
69 
70 // Y = alpha * ReduceL1(X)
71 template <typename T, class Context>
72 CAFFE2_API void ReduceL1(
73  const int ndim,
74  const int* X_dims,
75  const int* Y_dims,
76  const T alpha,
77  const T* X,
78  T* Y,
79  Context* context);
80 
81 // Y = alpha * ReduceL2(X)
82 template <typename T, class Context>
83 CAFFE2_API void ReduceL2(
84  const int ndim,
85  const int* X_dims,
86  const int* Y_dims,
87  const T alpha,
88  const T* X,
89  T* Y,
90  Context* context);
91 
92 // Computes mean and variance over axes.
93 template <typename T, class Context>
94 CAFFE2_API void Moments(
95  const int ndims,
96  const int* X_dims,
97  const int* Y_dims,
98  const T* X,
99  T* mean,
100  T* var,
101  Context* context);
102 
103 } // namespace math
104 
105 } // namespace caffe2
106 
107 #endif // CAFFE2_UTILS_MATH_REDUCE_H_
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13