Skip to content

Commit fe234fc

Browse files
authored
Revert "Register Torchvision Ops as Cutom Ops (#1267)" (#1316)
This reverts commit 78f169b.
1 parent e4d5003 commit fe234fc

File tree

12 files changed

+13
-199
lines changed

12 files changed

+13
-199
lines changed

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ before_install:
4747
- pip install future
4848
- pip install pytest pytest-cov codecov
4949
- pip install mock
50-
- |
51-
if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then
52-
pip install onnxruntime
53-
fi
5450
- conda install av -c conda-forge
5551

5652

setup.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,12 @@ def get_extensions():
9696
source_models = [os.path.join(models_dir, s) for s in source_models]
9797
tests = test_file + source_models
9898

99-
custom_ops_sources = [os.path.join(extensions_dir, "custom_ops", "custom_ops.cpp"),
100-
os.path.join(extensions_dir, "cpu", "nms_cpu.cpp"),
101-
os.path.join(extensions_dir, "cpu", "ROIAlign_cpu.cpp"),
102-
os.path.join(extensions_dir, "cpu", "ROIPool_cpu.cpp")]
103-
custom_ops_sources_cuda = [os.path.join(extensions_dir, "cuda", "nms_cuda.cu"),
104-
os.path.join(extensions_dir, "cuda", "ROIAlign_cuda.cu"),
105-
os.path.join(extensions_dir, "cuda", "ROIPool_cuda.cu")]
106-
10799
define_macros = []
108100

109101
extra_compile_args = {}
110102
if (torch.cuda.is_available() and CUDA_HOME is not None) or os.getenv('FORCE_CUDA', '0') == '1':
111103
extension = CUDAExtension
112104
sources += source_cuda
113-
custom_ops_sources += custom_ops_sources_cuda
114105
define_macros += [('WITH_CUDA', None)]
115106
nvcc_flags = os.getenv('NVCC_FLAGS', '')
116107
if nvcc_flags == '':
@@ -147,14 +138,7 @@ def get_extensions():
147138
include_dirs=tests_include_dirs,
148139
define_macros=define_macros,
149140
extra_compile_args=extra_compile_args,
150-
),
151-
extension(
152-
"torchvision._custom_ops",
153-
sources=custom_ops_sources,
154-
include_dirs=include_dirs,
155-
define_macros=define_macros,
156-
extra_compile_args=extra_compile_args,
157-
),
141+
)
158142
]
159143

160144
return ext_modules
@@ -195,6 +179,5 @@ def run(self):
195179
"scipy": ["scipy"],
196180
},
197181
ext_modules=get_extensions(),
198-
cmdclass={'build_ext': torch.utils.cpp_extension.BuildExtension,
199-
'clean': clean}
182+
cmdclass={'build_ext': torch.utils.cpp_extension.BuildExtension, 'clean': clean}
200183
)

test/test_onnx.py

Lines changed: 0 additions & 88 deletions
This file was deleted.

torchvision/csrc/ROIAlign.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
at::Tensor ROIAlign_forward(
1111
const at::Tensor& input, // Input feature map.
1212
const at::Tensor& rois, // List of ROIs to pool over.
13-
const double spatial_scale, // The scale of the image features. ROIs will be
13+
const float spatial_scale, // The scale of the image features. ROIs will be
1414
// scaled to this.
15-
const int64_t pooled_height, // The height of the pooled feature map.
16-
const int64_t pooled_width, // The width of the pooled feature
17-
const int64_t sampling_ratio) // The number of points to sample in each bin
15+
const int pooled_height, // The height of the pooled feature map.
16+
const int pooled_width, // The width of the pooled feature
17+
const int sampling_ratio) // The number of points to sample in each bin
1818
// along each axis.
1919
{
2020
if (input.type().is_cuda()) {

torchvision/csrc/ROIPool.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
std::tuple<at::Tensor, at::Tensor> ROIPool_forward(
1010
const at::Tensor& input,
1111
const at::Tensor& rois,
12-
const double spatial_scale,
13-
const int64_t pooled_height,
14-
const int64_t pooled_width) {
12+
const float spatial_scale,
13+
const int pooled_height,
14+
const int pooled_width) {
1515
if (input.type().is_cuda()) {
1616
#ifdef WITH_CUDA
1717
return ROIPool_forward_cuda(

torchvision/csrc/custom_ops/custom_ops.cpp

Lines changed: 0 additions & 14 deletions
This file was deleted.

torchvision/csrc/nms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
at::Tensor nms(
99
const at::Tensor& dets,
1010
const at::Tensor& scores,
11-
const double iou_threshold) {
11+
const float iou_threshold) {
1212
if (dets.device().is_cuda()) {
1313
#ifdef WITH_CUDA
1414
if (dets.numel() == 0) {

torchvision/csrc/vision.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#endif
88

99
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
10-
// TODO: remove nms from here since it is now registered
11-
// and used as a PyTorch custom op
1210
m.def("nms", &nms, "non-maximum suppression");
1311
m.def("roi_align_forward", &ROIAlign_forward, "ROIAlign_forward");
1412
m.def("roi_align_backward", &ROIAlign_backward, "ROIAlign_backward");

torchvision/ops/_custom_ops.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

torchvision/ops/boxes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import torch
2-
import torchvision.ops._custom_ops
2+
from torchvision.extension import _lazy_import
33

44

55
def nms(boxes, scores, iou_threshold):
@@ -29,7 +29,8 @@ def nms(boxes, scores, iou_threshold):
2929
of the elements that have been kept
3030
by NMS, sorted in decreasing order of scores
3131
"""
32-
return torch.ops.torchvision.nms(boxes, scores, iou_threshold)
32+
_C = _lazy_import()
33+
return _C.nms(boxes, scores, iou_threshold)
3334

3435

3536
def batched_nms(boxes, scores, idxs, iou_threshold):

0 commit comments

Comments
 (0)