ps_roi_pool.cpp 1.63 KB
Newer Older
1
#include "ps_roi_pool.h"
2
3

#include <torch/types.h>
4

5
6
namespace vision {
namespace ops {
7
8

std::tuple<at::Tensor, at::Tensor> ps_roi_pool(
9
10
    const at::Tensor& input,
    const at::Tensor& rois,
11
12
13
14
15
16
17
18
19
    double spatial_scale,
    int64_t pooled_height,
    int64_t pooled_width) {
  static auto op = c10::Dispatcher::singleton()
                       .findSchemaOrThrow("torchvision::ps_roi_pool", "")
                       .typed<decltype(ps_roi_pool)>();
  return op.call(input, rois, spatial_scale, pooled_height, pooled_width);
}

20
21
namespace detail {

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

50
51
} // namespace detail

52
53
54
55
56
57
58
TORCH_LIBRARY_FRAGMENT(torchvision, m) {
  m.def(
      "ps_roi_pool(Tensor input, Tensor rois, float spatial_scale, int pooled_height, int pooled_width) -> (Tensor, Tensor)");
  m.def(
      "_ps_roi_pool_backward(Tensor grad, Tensor rois, Tensor channel_mapping, float spatial_scale, int pooled_height, int pooled_width, int batch_size, int channels, int height, int width) -> Tensor");
}

59
60
} // namespace ops
} // namespace vision