roi_pool.cpp 1.6 KB
Newer Older
1
#include "roi_pool.h"
2
3

#include <torch/types.h>
4

5
6
namespace vision {
namespace ops {
7
8

std::tuple<at::Tensor, at::Tensor> 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::roi_pool", "")
                       .typed<decltype(roi_pool)>();
  return op.call(input, rois, spatial_scale, pooled_height, pooled_width);
}

20
21
namespace detail {

22
at::Tensor _roi_pool_backward(
23
24
25
    const at::Tensor& grad,
    const at::Tensor& rois,
    const at::Tensor& argmax,
26
27
28
29
30
31
32
33
34
35
36
    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::_roi_pool_backward", "")
                       .typed<decltype(_roi_pool_backward)>();
  return op.call(
37
38
39
40
41
42
43
44
45
46
      grad,
      rois,
      argmax,
      spatial_scale,
      pooled_height,
      pooled_width,
      batch_size,
      channels,
      height,
      width);
47
48
}

49
50
} // namespace detail

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

58
59
} // namespace ops
} // namespace vision