interpolate_aa.cpp 2.67 KB
Newer Older
1
2
#include "interpolate_aa.h"

3
4
#include <ATen/core/dispatch/Dispatcher.h>
#include <torch/library.h>
5
6
7
8
9
#include <torch/types.h>

namespace vision {
namespace ops {

10
at::Tensor _interpolate_bilinear2d_aa(
11
12
13
14
15
16
    const at::Tensor& input, // Input image
    at::IntArrayRef output_size, // Output image size
    bool align_corners) // The flag to align corners
{
  static auto op =
      c10::Dispatcher::singleton()
17
18
          .findSchemaOrThrow("torchvision::_interpolate_bilinear2d_aa", "")
          .typed<decltype(_interpolate_bilinear2d_aa)>();
19
20
21
  return op.call(input, output_size, align_corners);
}

22
at::Tensor _interpolate_bicubic_aa(
23
24
25
26
27
28
    const at::Tensor& input, // Input image
    at::IntArrayRef output_size, // Output image size
    bool align_corners) // The flag to align corners
{
  static auto op =
      c10::Dispatcher::singleton()
29
30
          .findSchemaOrThrow("torchvision::_interpolate_bicubic2d_aa", "")
          .typed<decltype(_interpolate_bicubic2d_aa)>();
31
32
33
  return op.call(input, output_size, align_corners);
}

34
35
namespace detail {

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
at::Tensor _interpolate_bilinear2d_aa_backward(
    const at::Tensor& grad_output,
    at::IntArrayRef output_size,
    at::IntArrayRef input_size,
    bool align_corners) {
  static auto op =
      c10::Dispatcher::singleton()
          .findSchemaOrThrow(
              "torchvision::_interpolate_bilinear2d_aa_backward", "")
          .typed<decltype(_interpolate_bilinear2d_aa_backward)>();
  return op.call(grad_output, output_size, output_size, align_corners);
}

at::Tensor _interpolate_bicubic2d_aa_backward(
    const at::Tensor& grad_output,
    at::IntArrayRef output_size,
    at::IntArrayRef input_size,
    bool align_corners) {
  static auto op =
      c10::Dispatcher::singleton()
          .findSchemaOrThrow(
              "torchvision::_interpolate_bicubic2d_aa_backward", "")
          .typed<decltype(_interpolate_bicubic2d_aa_backward)>();
  return op.call(grad_output, output_size, output_size, align_corners);
}
61
62
63
64
65

} // namespace detail

TORCH_LIBRARY_FRAGMENT(torchvision, m) {
  m.def(TORCH_SELECTIVE_SCHEMA(
66
67
68
69
70
      "torchvision::_interpolate_bilinear2d_aa(Tensor input, int[] output_size, bool align_corners) -> Tensor"));
  m.def(TORCH_SELECTIVE_SCHEMA(
      "torchvision::_interpolate_bicubic2d_aa(Tensor input, int[] output_size, bool align_corners) -> Tensor"));
  m.def(TORCH_SELECTIVE_SCHEMA(
      "torchvision::_interpolate_bilinear2d_aa_backward(Tensor input, int[] output_size, int[] input_size, bool align_corners) -> Tensor"));
71
  m.def(TORCH_SELECTIVE_SCHEMA(
72
      "torchvision::_interpolate_bicubic2d_aa_backward(Tensor input, int[] output_size, int[] input_size, bool align_corners) -> Tensor"));
73
74
75
76
}

} // namespace ops
} // namespace vision