MagmaDNN  1.0
c++NeuralNetworkFramework
reducesumop.h
1 
2 #pragma once
3 
4 #include "compute/operation.h"
5 #include "tensor/tensor.h"
6 #include "math/reduce_sum.h"
7 #include "compute/reducesum/reducesum_internal.h"
8 #include "utilities_internal.h"
9 
10 namespace magmadnn {
11 namespace op {
12 
13 template <typename T>
14 class ReduceSumOp : public Operation<T> {
15 public:
16  ReduceSumOp(Operation<T> *x, int axis, bool copy=true, bool needs_grad=true);
17 
18  virtual ~ReduceSumOp();
19 
20 
21  std::string to_string() { return "ReduceSum( " + x->to_string() + " )"; }
22 protected:
23  Tensor<T> *_eval(bool recompute=true);
25 
26  Operation<T> *x;
27  Tensor<T> *x_tensor;
28 
29  Tensor<T> *ones;
30 
31  #if defined(_HAS_CUDA_)
32  math::reduce_sum_cudnn_settings_t reduce_settings;
33  #endif
34 
35  int axis;
36  bool copy;
37 };
38 
39 template <typename T>
40 ReduceSumOp<T>* reducesum(Operation<T> *x, int axis, bool copy=true, bool needs_grad=true);
41 
42 } // namespace op
43 } // namespace magmadnn
std::string to_string()
Definition: reducesumop.h:21
Definition: reducesumop.h:14
Definition: addop.cpp:11
Definition: tensor.h:34
Tensor< T > * _grad(Operation< T > *consumer, Operation< T > *var, Tensor< T > *grad)
Definition: reducesumop.cpp:127
virtual Tensor< T > * grad(Operation< T > *consumer, Operation< T > *var, Tensor< T > *grad, bool recompute=true)
Definition: operation.h:93
virtual std::string to_string()=0
Tensor< T > * _eval(bool recompute=true)
Definition: reducesumop.cpp:109
Definition: operation.h:18
Variable< T > * var(std::string name, Tensor< T > *val)
Definition: variable.cpp:73