"vscode:/vscode.git/clone" did not exist on "896c07441ec12a3ff1b71e74905ba436f0f76501"
deform_conv2d.cpp 2.38 KB
Newer Older
1
#include "deform_conv2d.h"
2
3

#include <torch/types.h>
4

5
6
namespace vision {
namespace ops {
7
8

at::Tensor deform_conv2d(
9
10
11
    const at::Tensor& input,
    const at::Tensor& weight,
    const at::Tensor& offset,
12
    const at::Tensor& mask,
13
    const at::Tensor& bias,
14
15
16
17
18
19
20
    int64_t stride_h,
    int64_t stride_w,
    int64_t pad_h,
    int64_t pad_w,
    int64_t dilation_h,
    int64_t dilation_w,
    int64_t groups,
21
22
    int64_t offset_groups,
    bool use_mask) {
23
24
25
26
27
28
29
  static auto op = c10::Dispatcher::singleton()
                       .findSchemaOrThrow("torchvision::deform_conv2d", "")
                       .typed<decltype(deform_conv2d)>();
  return op.call(
      input,
      weight,
      offset,
30
      mask,
31
32
33
34
35
36
37
      bias,
      stride_h,
      stride_w,
      pad_h,
      pad_w,
      dilation_h,
      dilation_w,
38
      groups,
39
40
      offset_groups,
      use_mask);
41
42
}

43
44
namespace detail {

45
std::tuple<at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor>
46
47
48
49
50
_deform_conv2d_backward(
    const at::Tensor& grad,
    const at::Tensor& input,
    const at::Tensor& weight,
    const at::Tensor& offset,
51
    const at::Tensor& mask,
52
    const at::Tensor& bias,
53
54
55
56
57
58
59
    int64_t stride_h,
    int64_t stride_w,
    int64_t pad_h,
    int64_t pad_w,
    int64_t dilation_h,
    int64_t dilation_w,
    int64_t groups,
60
61
    int64_t offset_groups,
    bool use_mask) {
62
63
64
65
66
67
68
69
70
  static auto op =
      c10::Dispatcher::singleton()
          .findSchemaOrThrow("torchvision::_deform_conv2d_backward", "")
          .typed<decltype(_deform_conv2d_backward)>();
  return op.call(
      grad,
      input,
      weight,
      offset,
71
      mask,
72
73
74
75
76
77
78
      bias,
      stride_h,
      stride_w,
      pad_h,
      pad_w,
      dilation_h,
      dilation_w,
79
      groups,
80
81
      offset_groups,
      use_mask);
82
83
}

84
85
} // namespace detail

86
87
88
89
90
91
92
TORCH_LIBRARY_FRAGMENT(torchvision, m) {
  m.def(
      "deform_conv2d(Tensor input, Tensor weight, Tensor offset, Tensor mask, Tensor bias, int stride_h, int stride_w, int pad_h, int pad_w, int dilation_h, int dilation_w, int groups, int offset_groups, bool use_mask) -> Tensor");
  m.def(
      "_deform_conv2d_backward(Tensor grad, Tensor input, Tensor weight, Tensor offset, Tensor mask, Tensor bias, int stride_h, int stride_w, int pad_h, int pad_w, int dilation_h, int dilation_w, int groups, int offset_groups, bool use_mask) -> (Tensor, Tensor, Tensor, Tensor, Tensor)");
}

93
94
} // namespace ops
} // namespace vision