ps_roi_align.cpp 1.92 KB
Newer Older
1
#include "ps_roi_align.h"
2
3

#include <torch/types.h>
4

5
6
namespace vision {
namespace ops {
7
8

std::tuple<at::Tensor, at::Tensor> ps_roi_align(
9
10
    const at::Tensor& input,
    const at::Tensor& rois,
11
12
13
14
    double spatial_scale,
    int64_t pooled_height,
    int64_t pooled_width,
    int64_t sampling_ratio) {
Kai Zhang's avatar
Kai Zhang committed
15
  C10_LOG_API_USAGE_ONCE("torchvision.csrc.ops.ps_roi_align.ps_roi_align");
16
17
18
19
  static auto op = c10::Dispatcher::singleton()
                       .findSchemaOrThrow("torchvision::ps_roi_align", "")
                       .typed<decltype(ps_roi_align)>();
  return op.call(
20
21
22
      input, rois, spatial_scale, pooled_height, pooled_width, sampling_ratio);
}

23
24
namespace detail {

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
at::Tensor _ps_roi_align_backward(
    const at::Tensor& grad,
    const at::Tensor& rois,
    const at::Tensor& channel_mapping,
    double spatial_scale,
    int64_t pooled_height,
    int64_t pooled_width,
    int64_t sampling_ratio,
    int64_t batch_size,
    int64_t channels,
    int64_t height,
    int64_t width) {
  static auto op =
      c10::Dispatcher::singleton()
          .findSchemaOrThrow("torchvision::_ps_roi_align_backward", "")
          .typed<decltype(_ps_roi_align_backward)>();
  return op.call(
42
43
      grad,
      rois,
44
      channel_mapping,
45
46
47
48
49
50
51
52
53
54
      spatial_scale,
      pooled_height,
      pooled_width,
      sampling_ratio,
      batch_size,
      channels,
      height,
      width);
}

55
56
} // namespace detail

57
TORCH_LIBRARY_FRAGMENT(torchvision, m) {
58
59
60
61
  m.def(TORCH_SELECTIVE_SCHEMA(
      "torchvision::ps_roi_align(Tensor input, Tensor rois, float spatial_scale, int pooled_height, int pooled_width, int sampling_ratio) -> (Tensor, Tensor)"));
  m.def(TORCH_SELECTIVE_SCHEMA(
      "torchvision::_ps_roi_align_backward(Tensor grad, Tensor rois, Tensor channel_mapping, float spatial_scale, int pooled_height, int pooled_width, int sampling_ratio, int batch_size, int channels, int height, int width) -> Tensor"));
62
63
}

64
65
} // namespace ops
} // namespace vision