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

#ifdef WITH_CUDA
#include <cuda.h>
#endif

8
#include "DeformConv.h"
9
10
#include "PSROIAlign.h"
#include "PSROIPool.h"
11
12
#include "ROIAlign.h"
#include "ROIPool.h"
eellison's avatar
eellison committed
13
#include "empty_tensor_op.h"
14
15
#include "nms.h"

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

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

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