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