Skip to content

Commit 8fb19e4

Browse files
authored
Merge branch 'master' into vfdev-5/issue-2651-contributing
2 parents 79a50f1 + ce34258 commit 8fb19e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+350
-973
lines changed

.circleci/config.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ jobs:
132132
sudo mv clang-format /opt/clang-format
133133
./travis-scripts/run-clang-format/run-clang-format.py -r torchvision/csrc --clang-format-executable /opt/clang-format
134134
135+
torchhub_test:
136+
docker:
137+
- image: circleci/python:3.7
138+
steps:
139+
- checkout
140+
- run:
141+
command: |
142+
pip install --user --progress-bar off numpy
143+
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
144+
# need to install torchvision dependencies due to transitive imports
145+
pip install --user --progress-bar off --editable .
146+
python test/test_hub.py
147+
135148
binary_linux_wheel:
136149
<<: *binary_common
137150
docker:
@@ -1060,6 +1073,7 @@ workflows:
10601073
- python_lint
10611074
- python_type_check
10621075
- clang_format
1076+
- torchhub_test
10631077

10641078
unittest:
10651079
jobs:
@@ -1174,6 +1188,7 @@ workflows:
11741188
- python_lint
11751189
- python_type_check
11761190
- clang_format
1191+
- torchhub_test
11771192
- binary_linux_wheel:
11781193
cu_version: cpu
11791194
filters:

.circleci/config.yml.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ jobs:
132132
sudo mv clang-format /opt/clang-format
133133
./travis-scripts/run-clang-format/run-clang-format.py -r torchvision/csrc --clang-format-executable /opt/clang-format
134134

135+
torchhub_test:
136+
docker:
137+
- image: circleci/python:3.7
138+
steps:
139+
- checkout
140+
- run:
141+
command: |
142+
pip install --user --progress-bar off numpy
143+
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
144+
# need to install torchvision dependencies due to transitive imports
145+
pip install --user --progress-bar off --editable .
146+
python test/test_hub.py
147+
135148
binary_linux_wheel:
136149
<<: *binary_common
137150
docker:
@@ -686,6 +699,7 @@ workflows:
686699
- python_lint
687700
- python_type_check
688701
- clang_format
702+
- torchhub_test
689703

690704
unittest:
691705
jobs:
@@ -702,6 +716,7 @@ workflows:
702716
- python_lint
703717
- python_type_check
704718
- clang_format
719+
- torchhub_test
705720
{{ build_workflows(prefix="nightly_", filter_branch="nightly", upload=True) }}
706721
docker_build:
707722
triggers:

.travis.yml

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

test/fakedata_generation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _encode(v):
2121
return torch.tensor(v, dtype=torch.int32).numpy().tobytes()[::-1]
2222

2323
def _make_image_file(filename, num_images):
24-
img = torch.randint(0, 255, size=(28 * 28 * num_images,), dtype=torch.uint8)
24+
img = torch.randint(0, 256, size=(28 * 28 * num_images,), dtype=torch.uint8)
2525
with open(filename, "wb") as f:
2626
f.write(_encode(2051)) # magic header
2727
f.write(_encode(num_images))

test/test_datasets_samplers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_list_of_videos(num_videos=5, sizes=None, fps=None):
2929
f = 5
3030
else:
3131
f = fps[i]
32-
data = torch.randint(0, 255, (size, 300, 400, 3), dtype=torch.uint8)
32+
data = torch.randint(0, 256, (size, 300, 400, 3), dtype=torch.uint8)
3333
name = os.path.join(tmp_dir, "{}.mp4".format(i))
3434
names.append(name)
3535
io.write_video(name, data, fps=f)

test/test_datasets_video_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_list_of_videos(num_videos=5, sizes=None, fps=None):
2222
f = 5
2323
else:
2424
f = fps[i]
25-
data = torch.randint(0, 255, (size, 300, 400, 3), dtype=torch.uint8)
25+
data = torch.randint(0, 256, (size, 300, 400, 3), dtype=torch.uint8)
2626
name = os.path.join(tmp_dir, "{}.mp4".format(i))
2727
names.append(name)
2828
io.write_video(name, data, fps=f)

test/test_transforms_tensor.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_center_crop(self):
180180
self._test_op(
181181
"center_crop", "CenterCrop", fn_kwargs=fn_kwargs, meth_kwargs=meth_kwargs
182182
)
183-
tensor = torch.randint(0, 255, (3, 10, 10), dtype=torch.uint8, device=self.device)
183+
tensor = torch.randint(0, 256, (3, 10, 10), dtype=torch.uint8, device=self.device)
184184
# Test torchscript of transforms.CenterCrop with size as int
185185
f = T.CenterCrop(size=5)
186186
scripted_fn = torch.jit.script(f)
@@ -294,7 +294,7 @@ def test_resize(self):
294294
self.assertEqual(y.shape[2], int(38 * 46 / 32))
295295

296296
tensor, _ = self._create_data(height=34, width=36, device=self.device)
297-
batch_tensors = torch.randint(0, 255, size=(4, 3, 44, 56), dtype=torch.uint8, device=self.device)
297+
batch_tensors = torch.randint(0, 256, size=(4, 3, 44, 56), dtype=torch.uint8, device=self.device)
298298
script_fn = torch.jit.script(F.resize)
299299

300300
for dt in [None, torch.float32, torch.float64]:
@@ -323,8 +323,8 @@ def test_resize(self):
323323
script_fn.save(os.path.join(tmp_dir, "t_resize.pt"))
324324

325325
def test_resized_crop(self):
326-
tensor = torch.randint(0, 255, size=(3, 44, 56), dtype=torch.uint8, device=self.device)
327-
batch_tensors = torch.randint(0, 255, size=(4, 3, 44, 56), dtype=torch.uint8, device=self.device)
326+
tensor = torch.randint(0, 256, size=(3, 44, 56), dtype=torch.uint8, device=self.device)
327+
batch_tensors = torch.randint(0, 256, size=(4, 3, 44, 56), dtype=torch.uint8, device=self.device)
328328

329329
for scale in [(0.7, 1.2), [0.7, 1.2]]:
330330
for ratio in [(0.75, 1.333), [0.75, 1.333]]:
@@ -341,8 +341,8 @@ def test_resized_crop(self):
341341
s_transform.save(os.path.join(tmp_dir, "t_resized_crop.pt"))
342342

343343
def test_random_affine(self):
344-
tensor = torch.randint(0, 255, size=(3, 44, 56), dtype=torch.uint8, device=self.device)
345-
batch_tensors = torch.randint(0, 255, size=(4, 3, 44, 56), dtype=torch.uint8, device=self.device)
344+
tensor = torch.randint(0, 256, size=(3, 44, 56), dtype=torch.uint8, device=self.device)
345+
batch_tensors = torch.randint(0, 256, size=(4, 3, 44, 56), dtype=torch.uint8, device=self.device)
346346

347347
for shear in [15, 10.0, (5.0, 10.0), [-15, 15], [-10.0, 10.0, -11.0, 11.0]]:
348348
for scale in [(0.7, 1.2), [0.7, 1.2]]:
@@ -363,8 +363,8 @@ def test_random_affine(self):
363363
s_transform.save(os.path.join(tmp_dir, "t_random_affine.pt"))
364364

365365
def test_random_rotate(self):
366-
tensor = torch.randint(0, 255, size=(3, 44, 56), dtype=torch.uint8, device=self.device)
367-
batch_tensors = torch.randint(0, 255, size=(4, 3, 44, 56), dtype=torch.uint8, device=self.device)
366+
tensor = torch.randint(0, 256, size=(3, 44, 56), dtype=torch.uint8, device=self.device)
367+
batch_tensors = torch.randint(0, 256, size=(4, 3, 44, 56), dtype=torch.uint8, device=self.device)
368368

369369
for center in [(0, 0), [10, 10], None, (56, 44)]:
370370
for expand in [True, False]:
@@ -383,8 +383,8 @@ def test_random_rotate(self):
383383
s_transform.save(os.path.join(tmp_dir, "t_random_rotate.pt"))
384384

385385
def test_random_perspective(self):
386-
tensor = torch.randint(0, 255, size=(3, 44, 56), dtype=torch.uint8, device=self.device)
387-
batch_tensors = torch.randint(0, 255, size=(4, 3, 44, 56), dtype=torch.uint8, device=self.device)
386+
tensor = torch.randint(0, 256, size=(3, 44, 56), dtype=torch.uint8, device=self.device)
387+
batch_tensors = torch.randint(0, 256, size=(4, 3, 44, 56), dtype=torch.uint8, device=self.device)
388388

389389
for distortion_scale in np.linspace(0.1, 1.0, num=20):
390390
for interpolation in [NEAREST, BILINEAR]:

test/tracing/frcnn/test_frcnn_tracing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#include <ATen/ATen.h>
22
#include <torch/script.h>
33
#include <torch/torch.h>
4-
#include <torchvision/roi_align.h>
54
#include <torchvision/nms.h>
5+
#include <torchvision/roi_align.h>
66

77
#ifdef _WIN32
88
// Windows only
99
// This is necessary until operators are automatically registered on include
10-
static auto _nms = &vision::ops::nms_cpu;
10+
static auto _nms = &vision::ops::nms;
1111
#endif
1212

1313
int main() {

torchvision/csrc/cpu/deform_conv2d_kernel.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
// modified from
6767
// https://github.com/open-mmlab/mmdetection/blob/master/mmdet/ops/dcn/src/deform_conv_cuda.cpp
6868

69-
#include "deform_conv2d_kernel.h"
69+
#include <ATen/ATen.h>
70+
#include <torch/library.h>
7071

7172
namespace vision {
7273
namespace ops {
@@ -852,9 +853,7 @@ at::Tensor backward_gradient_parameters(
852853
return grad_weight;
853854
}
854855

855-
} // namespace
856-
857-
at::Tensor deform_conv2d_forward_cpu(
856+
at::Tensor deform_conv2d_forward_kernel(
858857
const at::Tensor& input,
859858
const at::Tensor& weight,
860859
const at::Tensor& offset,
@@ -1070,7 +1069,7 @@ at::Tensor deform_conv2d_forward_cpu(
10701069
}
10711070

10721071
std::tuple<at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor>
1073-
deform_conv2d_backward_cpu(
1072+
deform_conv2d_backward_kernel(
10741073
const at::Tensor& grad_out,
10751074
const at::Tensor& input,
10761075
const at::Tensor& weight,
@@ -1141,5 +1140,12 @@ deform_conv2d_backward_cpu(
11411140
grad_input, grad_weight, grad_offset, grad_mask, grad_bias);
11421141
}
11431142

1143+
} // namespace
1144+
1145+
TORCH_LIBRARY_IMPL(torchvision, CPU, m) {
1146+
m.impl("deform_conv2d", deform_conv2d_forward_kernel);
1147+
m.impl("_deform_conv2d_backward", deform_conv2d_backward_kernel);
1148+
}
1149+
11441150
} // namespace ops
11451151
} // namespace vision

torchvision/csrc/cpu/deform_conv2d_kernel.h

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

torchvision/csrc/cpu/nms_kernel.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#include "nms_kernel.h"
1+
#include <ATen/ATen.h>
2+
#include <torch/library.h>
23

34
namespace vision {
45
namespace ops {
@@ -74,9 +75,7 @@ at::Tensor nms_kernel_impl(
7475
return keep_t.narrow(/*dim=*/0, /*start=*/0, /*length=*/num_to_keep);
7576
}
7677

77-
} // namespace
78-
79-
at::Tensor nms_cpu(
78+
at::Tensor nms_kernel(
8079
const at::Tensor& dets,
8180
const at::Tensor& scores,
8281
double iou_threshold) {
@@ -101,11 +100,17 @@ at::Tensor nms_cpu(
101100

102101
auto result = at::empty({0}, dets.options());
103102

104-
AT_DISPATCH_FLOATING_TYPES(dets.scalar_type(), "nms_cpu", [&] {
103+
AT_DISPATCH_FLOATING_TYPES(dets.scalar_type(), "nms_kernel", [&] {
105104
result = nms_kernel_impl<scalar_t>(dets, scores, iou_threshold);
106105
});
107106
return result;
108107
}
109108

109+
} // namespace
110+
111+
TORCH_LIBRARY_IMPL(torchvision, CPU, m) {
112+
m.impl("nms", nms_kernel);
113+
}
114+
110115
} // namespace ops
111116
} // namespace vision

torchvision/csrc/cpu/nms_kernel.h

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

0 commit comments

Comments
 (0)