forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDepthwiseConv2d.cu
54 lines (46 loc) · 1.58 KB
/
DepthwiseConv2d.cu
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
#include <ATen/ATen.h>
#include <ATen/LegacyTHFunctionsCUDA.h>
namespace at {
namespace native {
std::tuple<Tensor &,Tensor &> thnn_conv_depthwise2d_backward_out(
Tensor & grad_input,
Tensor & grad_weight,
const Tensor & grad_output,
const Tensor & self,
const Tensor & weight,
IntArrayRef kernel_size,
IntArrayRef stride,
IntArrayRef padding,
IntArrayRef dilation) {
if (grad_weight.defined()) {
grad_weight.resize_(weight.sizes());
grad_weight.zero_();
}
return legacy::cuda::_thnn_conv_depthwise2d_backward_out(grad_input, grad_weight,
grad_output, self, weight,
kernel_size, stride, padding, dilation);
}
std::tuple<Tensor, Tensor> thnn_conv_depthwise2d_backward(
const Tensor& grad_output,
const Tensor& self,
const Tensor& weight,
IntArrayRef kernel_size,
IntArrayRef stride,
IntArrayRef padding,
IntArrayRef dilation,
std::array<bool, 2> output_mask) {
Tensor grad_input;
Tensor grad_weight;
if (output_mask[0]) {
grad_input = at::empty({0}, grad_output.options());
}
if (output_mask[1]) {
grad_weight = at::empty({0}, grad_output.options());
}
return native::thnn_conv_depthwise2d_backward_out(grad_input, grad_weight,
grad_output, self, weight,
kernel_size, stride, padding,
dilation);
}
} // namespace native
} // namespace at