Dragon - C++ API
A Computation Graph Virtual Machine Based Deep Learning Framework
depthwise_conv_op.h
Go to the documentation of this file.
1 
13 #ifndef DRAGON_OPERATORS_VISION_DEPTHWISE_CONV_OP_H_
14 #define DRAGON_OPERATORS_VISION_DEPTHWISE_CONV_OP_H_
15 
17 
18 namespace dragon {
19 
20 template <class Context>
22  : public ConvOpBase<Context> {
23  public:
25  const OperatorDef& def,
26  Workspace* ws)
27  : ConvOpBase<Context>(def, ws) { Setup(2); }
30 
31  bool Transposed() override { return false; }
32  bool HasBias() override { return XSize() > 2; }
33 
34  void RunOnDevice() override;
35  template <typename T> void RunImpl();
36 };
37 
38 template <class Context>
40  : public DepthwiseConv2dOp<Context> {
41  public:
43  const OperatorDef& def,
44  Workspace* ws)
45  : DepthwiseConv2dOp<Context>(def, ws) {}
48 
49  bool HasBias() override {
50  return Y(2)->name() != "NULL";
51  }
52 
53  void RunOnDevice() override;
54  template <typename T> void RunImpl();
55 };
56 
57 #ifdef WITH_CUDNN
58 
59 template <class Context>
61  : public DepthwiseConv2dOp<Context> {
62  public:
64  const OperatorDef& def,
65  Workspace* ws)
66  : DepthwiseConv2dOp<Context>(def, ws) {
69  }
72 
76  }
77 
78  void RunOnDevice() override;
79  template <typename T> void RunImpl();
80 
81  protected:
82  cudnnTensorDescriptor_t bias_desc_;
83  cudnnTensorDescriptor_t output_desc_;
84 };
85 
86 template <class Context>
88  : public Conv2dGradientOp<Context> {
89  public:
91  const OperatorDef& def,
92  Workspace* ws)
93  : Conv2dGradientOp<Context>(def, ws) {
96  }
99 
103  }
104 
105  void RunOnDevice() override;
106  template <typename T> void RunImpl();
107 
108  protected:
109  cudnnTensorDescriptor_t bias_desc_;
110  cudnnTensorDescriptor_t input_desc_;
111 };
112 
113 #endif // WITH_CUDNN
114 
115 } // namespace dragon
116 
117 #endif // DRAGON_OPERATORS_VISION_DEPTHWISE_CONV_OP_H_
void RunImpl()
Definition: cudnn_depthwise_conv2d_op.cc:11
Definition: workspace.h:20
void RunImpl()
Definition: depthwise_conv2d_op.cc:9
void RunImpl()
Definition: cudnn_depthwise_conv2d_op.cc:76
DepthwiseConv2dOp(const OperatorDef &def, Workspace *ws)
Definition: depthwise_conv_op.h:24
USE_CONVOLUTION_FUNCTIONS
Definition: depthwise_conv_op.h:47
cudnnTensorDescriptor_t bias_desc_
Definition: depthwise_conv_op.h:109
void RunOnDevice() override
Implement the detailed execution.
Definition: cudnn_depthwise_conv2d_op.cc:64
USE_CONVOLUTION_FUNCTIONS
Definition: depthwise_conv_op.h:71
Definition: depthwise_conv_op.h:39
const OperatorDef & def() const
Return the stored def.
Definition: operator.h:114
Workspace * ws() const
Return the parent workspace.
Definition: operator.h:87
USE_OPERATOR_FUNCTIONS
Definition: depthwise_conv_op.h:46
~CuDNNDepthwiseConv2dOp()
Definition: depthwise_conv_op.h:73
USE_CONVOLUTION_FUNCTIONS
Definition: depthwise_conv_op.h:29
CuDNNDepthwiseConv2dGradientOp(const OperatorDef &def, Workspace *ws)
Definition: depthwise_conv_op.h:90
bool Transposed() override
Definition: depthwise_conv_op.h:31
void CuDNNCreateTensorDesc(cudnnTensorDescriptor_t *desc)
Definition: cudnn_device.h:67
USE_OPERATOR_FUNCTIONS
Definition: depthwise_conv_op.h:28
USE_OPERATOR_FUNCTIONS
Definition: depthwise_conv_op.h:70
void RunOnDevice() override
Implement the detailed execution.
Definition: cudnn_depthwise_conv2d_op.cc:145
void RunImpl()
Definition: depthwise_conv2d_op.cc:48
int XSize()
Return the number of inputs.
Definition: operator.h:46
cudnnTensorDescriptor_t output_desc_
Definition: depthwise_conv_op.h:83
void Setup(int num_axes)
Definition: conv_op_base.cc:248
CuDNNDepthwiseConv2dOp(const OperatorDef &def, Workspace *ws)
Definition: depthwise_conv_op.h:63
void RunOnDevice() override
Implement the detailed execution.
Definition: depthwise_conv2d_op.cc:36
Definition: depthwise_conv_op.h:60
void RunOnDevice() override
Implement the detailed execution.
Definition: depthwise_conv2d_op.cc:91
~CuDNNDepthwiseConv2dGradientOp()
Definition: depthwise_conv_op.h:100
bool HasBias() override
Definition: depthwise_conv_op.h:32
cudnnTensorDescriptor_t input_desc_
Definition: depthwise_conv_op.h:110
void CuDNNDestroyTensorDesc(cudnnTensorDescriptor_t *desc)
Definition: cudnn_device.h:72
bool HasBias() override
Definition: depthwise_conv_op.h:49
Definition: depthwise_conv_op.h:87
Definition: depthwise_conv_op.h:21
DepthwiseConv2dGradientOp(const OperatorDef &def, Workspace *ws)
Definition: depthwise_conv_op.h:42
Tensor * Y(int i)
Return the specified output tensor.
Definition: operator.cc:55
cudnnTensorDescriptor_t bias_desc_
Definition: depthwise_conv_op.h:82
const string & name() const
Return the tensor name.
Definition: tensor.h:69
Definition: common.h:41
USE_OPERATOR_FUNCTIONS
Definition: depthwise_conv_op.h:97
Definition: conv_op_base.h:23
USE_CONVOLUTION_FUNCTIONS
Definition: depthwise_conv_op.h:98
Definition: conv_op.h:36