vision.cpp 1.38 KB
Newer Older
1
2
3
4
5
6
#include <Python.h>
#include <torch/script.h>

#ifdef WITH_CUDA
#include <cuda.h>
#endif
7
8
9
#ifdef WITH_HIP
#include <hip/hip_runtime.h>
#endif
10

11
#include "DeformConv.h"
12
13
#include "PSROIAlign.h"
#include "PSROIPool.h"
14
15
#include "ROIAlign.h"
#include "ROIPool.h"
eellison's avatar
eellison committed
16
#include "empty_tensor_op.h"
17
18
#include "nms.h"

19
// If we are in a Windows environment, we need to define
20
// initialization functions for the _C extension
21
22
#ifdef _WIN32
#if PY_MAJOR_VERSION < 3
23
PyMODINIT_FUNC init_C(void) {
24
  // No need to do anything.
25
  // extension.py will run on load
26
27
28
  return NULL;
}
#else
29
PyMODINIT_FUNC PyInit__C(void) {
30
  // No need to do anything.
31
  // extension.py will run on load
32
33
34
  return NULL;
}
#endif
35
36
#endif

37
int64_t _cuda_version() {
38
#ifdef WITH_CUDA
39
40
41
  return CUDA_VERSION;
#else
  return -1;
42
#endif
43
}
44
45
46
47

static auto registry =
    torch::RegisterOperators()
        .op("torchvision::nms", &nms)
AhnDW's avatar
AhnDW committed
48
        .op("torchvision::roi_align(Tensor input, Tensor rois, float spatial_scale, int pooled_height, int pooled_width, int sampling_ratio, bool aligned) -> Tensor",
49
50
            &roi_align)
        .op("torchvision::roi_pool", &roi_pool)
eellison's avatar
eellison committed
51
        .op("torchvision::_new_empty_tensor_op", &new_empty_tensor)
52
53
        .op("torchvision::ps_roi_align", &ps_roi_align)
        .op("torchvision::ps_roi_pool", &ps_roi_pool)
54
        .op("torchvision::deform_conv2d", &deform_conv2d)
55
        .op("torchvision::_cuda_version", &_cuda_version);