vision.cpp 1.35 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
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// If we are in a Windows environment, we need to define
// initialization functions for the _custom_ops extension
#ifdef _WIN32
#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_custom_ops(void) {
  // No need to do anything.
  // _custom_ops.py will run on load
  return NULL;
}
#else
PyMODINIT_FUNC PyInit__custom_ops(void) {
  // No need to do anything.
  // _custom_ops.py will run on load
  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);