MagmaDNN  1.0
c++NeuralNetworkFramework
reluop.h
Go to the documentation of this file.
1 
9 #pragma once
10 #include "compute/operation.h"
11 #include "math/relu.h"
13 #include "tensor/tensor.h"
14 
15 namespace magmadnn {
16 namespace op {
17 
18 template <typename T>
19 class ReluOp : public Operation<T> {
20 public:
21  ReluOp(Operation<T> *x, bool copy=true, bool needs_grad=true);
22  virtual ~ReluOp();
23 
24  std::string to_string() { return "RELU( " + x->to_string() + " )"; }
25 
26 protected:
27  Tensor<T> *_eval(bool recompute=true);
29 
30  Operation<T> *x;
31  Tensor<T> *x_tensor;
32 
33  #if defined(_HAS_CUDA_)
34  ::magmadnn::math::relu_cudnn_settings_t cudnn_settings;
35  #endif
36 
37  bool copy;
38 };
39 
40 template <typename T>
41 ReluOp<T> *relu(Operation<T> *x, bool copy=true, bool needs_grad=true);
42 
43 
44 } // namespace op
45 } // namespace magmadnn
Definition: addop.cpp:11
Definition: tensor.h:34
std::string to_string()
Definition: reluop.h:24
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 > * _grad(Operation< T > *consumer, Operation< T > *var, Tensor< T > *grad)
Definition: reluop.cpp:61
Definition: operation.h:18
Variable< T > * var(std::string name, Tensor< T > *val)
Definition: variable.cpp:73
Definition: reluop.h:19
Tensor< T > * _eval(bool recompute=true)
Definition: reluop.cpp:40