Dragon - C++ API
A Computation Graph Virtual Machine Based Deep Learning Framework
bias_add_op.h
Go to the documentation of this file.
1 
13 #ifndef DRAGON_OPERATORS_VISION_BIAS_ADD_OP_H_
14 #define DRAGON_OPERATORS_VISION_BIAS_ADD_OP_H_
15 
16 #include "core/operator.h"
17 
18 namespace dragon {
19 
20 template <class Context>
21 class BiasAddOp final : public Operator<Context> {
22  public:
25 
26  void RunOnDevice() override;
27  template <typename T> void RunImpl();
28 
29  protected:
31 };
32 
33 template <class Context>
34 class BiasAddGradientOp final : public Operator<Context> {
35  public:
38 
39  void RunOnDevice() override;
40  template <typename T> void RunImpl();
41 
42  protected:
44 };
45 
46 #ifdef WITH_CUDNN
47 
48 template <class Context>
49 class CuDNNBiasAddOp final : public Operator<Context> {
50  public:
51  CuDNNBiasAddOp(const OperatorDef& def, Workspace* ws)
52  : Operator<Context>(def, ws) {
55  }
57 
61  }
62 
63  void RunOnDevice() override;
64  template <typename T> void RunImpl();
65 
66  protected:
68  cudnnTensorDescriptor_t bias_desc_;
69  cudnnTensorDescriptor_t output_desc_;
70 };
71 
72 template <class Context>
73 class CuDNNBiasAddGradientOp final : public Operator<Context> {
74 public:
75  CuDNNBiasAddGradientOp(const OperatorDef& def, Workspace* ws)
76  : Operator<Context>(def, ws) {
79  }
81 
85  }
86 
87  void RunOnDevice() override;
88  template <typename T> void RunImpl();
89 
90 protected:
92  cudnnTensorDescriptor_t bias_desc_;
93  cudnnTensorDescriptor_t input_desc_;
94 };
95 
96 #endif // WITH_CUDNN
97 
98 } // namespace dragon
99 
100 #endif // DRAGON_OPERATORS_VISION_BIAS_ADD_OP_H_
~CuDNNBiasAddGradientOp()
Definition: bias_add_op.h:82
CuDNNBiasAddOp(const OperatorDef &def, Workspace *ws)
Definition: bias_add_op.h:51
Definition: workspace.h:20
int64_t outer_dim_
Definition: bias_add_op.h:43
void RunImpl()
Definition: cudnn_bias_add_op.cc:10
void RunOnDevice() override
Implement the detailed execution.
Definition: cudnn_bias_add_op.cc:49
int64_t axis_dim_
Definition: bias_add_op.h:43
USE_OPERATOR_FUNCTIONS
Definition: bias_add_op.h:24
void RunImpl()
Definition: bias_add_op.cc:10
const OperatorDef & def() const
Return the stored def.
Definition: operator.h:114
void RunOnDevice() override
Implement the detailed execution.
Definition: bias_add_op.cc:85
Workspace * ws() const
Return the parent workspace.
Definition: operator.h:87
CuDNNBiasAddGradientOp(const OperatorDef &def, Workspace *ws)
Definition: bias_add_op.h:75
int64_t outer_dim_
Definition: bias_add_op.h:91
int64_t inner_dim_
Definition: bias_add_op.h:43
void CuDNNCreateTensorDesc(cudnnTensorDescriptor_t *desc)
Definition: cudnn_device.h:67
void RunImpl()
Definition: bias_add_op.cc:51
Definition: operator.h:149
int64_t inner_dim_
Definition: bias_add_op.h:30
Definition: bias_add_op.h:73
SIMPLE_CTOR_DTOR(BiasAddGradientOp)
int64_t axis_dim_
Definition: bias_add_op.h:30
void RunOnDevice() override
Implement the detailed execution.
Definition: cudnn_bias_add_op.cc:110
int64_t axis_dim_
Definition: bias_add_op.h:91
void RunOnDevice() override
Implement the detailed execution.
Definition: bias_add_op.cc:31
int64_t outer_dim_
Definition: bias_add_op.h:30
cudnnTensorDescriptor_t bias_desc_
Definition: bias_add_op.h:68
cudnnTensorDescriptor_t output_desc_
Definition: bias_add_op.h:69
void CuDNNDestroyTensorDesc(cudnnTensorDescriptor_t *desc)
Definition: cudnn_device.h:72
Definition: bias_add_op.h:49
Definition: bias_add_op.h:34
int64_t inner_dim_
Definition: bias_add_op.h:91
USE_OPERATOR_FUNCTIONS
Definition: bias_add_op.h:56
int64_t outer_dim_
Definition: bias_add_op.h:67
void RunImpl()
Definition: cudnn_bias_add_op.cc:70
~CuDNNBiasAddOp()
Definition: bias_add_op.h:58
cudnnTensorDescriptor_t bias_desc_
Definition: bias_add_op.h:92
USE_OPERATOR_FUNCTIONS
Definition: bias_add_op.h:80
SIMPLE_CTOR_DTOR(BiasAddOp)
USE_OPERATOR_FUNCTIONS
Definition: bias_add_op.h:37
Definition: common.h:41
int64_t axis_dim_
Definition: bias_add_op.h:67
cudnnTensorDescriptor_t input_desc_
Definition: bias_add_op.h:93
Definition: bias_add_op.h:21
int64_t inner_dim_
Definition: bias_add_op.h:67