Skip to content

Commit 1bae81c

Browse files
fmassafacebook-github-bot
authored andcommitted
Remove _new_empty_tensor. (#3156)
Summary: Co-authored-by: Francisco Massa <fvsmassa@gmail.com> Reviewed By: datumbox Differential Revision: D25531033 fbshipit-source-id: 735bdd211edfb49bc97fae8558049214d6a4b169
1 parent ef5ea8b commit 1bae81c

File tree

7 files changed

+1
-110
lines changed

7 files changed

+1
-110
lines changed

test/test_onnx.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,6 @@ def to_numpy(tensor):
7676
else:
7777
raise
7878

79-
@unittest.skip("Disable test until Split w/ zero sizes is implemented in ORT")
80-
def test_new_empty_tensor(self):
81-
class Module(torch.nn.Module):
82-
def __init__(self):
83-
super(Module, self).__init__()
84-
self.conv2 = ops.misc.ConvTranspose2d(16, 33, (3, 5))
85-
86-
def forward(self, input2):
87-
return self.conv2(input2)
88-
89-
input = torch.rand(0, 16, 10, 10)
90-
test_input = torch.rand(0, 16, 20, 20)
91-
self.run_model(Module(), [(input, ), (test_input,)], do_constant_folding=False)
92-
9379
def test_nms(self):
9480
boxes = torch.rand(5, 4)
9581
boxes[:, 2:] += torch.rand(5, 2)

test/test_ops.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -449,15 +449,6 @@ def test_autocast(self):
449449
self.test_nms_cuda(dtype=dtype)
450450

451451

452-
class NewEmptyTensorTester(unittest.TestCase):
453-
def test_new_empty_tensor(self):
454-
input = torch.tensor([2., 2.], requires_grad=True)
455-
new_shape = [3, 3]
456-
out = torch.ops.torchvision._new_empty_tensor_op(input, new_shape)
457-
assert out.size() == torch.Size([3, 3])
458-
assert out.dtype == input.dtype
459-
460-
461452
class DeformConvTester(OpTester, unittest.TestCase):
462453
def expected_fn(self, x, weight, offset, mask, bias, stride=1, padding=0, dilation=1):
463454
stride_h, stride_w = _pair(stride)

torchvision/csrc/ops/new_empty_tensor_op.cpp

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

torchvision/csrc/ops/new_empty_tensor_op.h

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

torchvision/ops/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from .boxes import nms, batched_nms, remove_small_boxes, clip_boxes_to_image, box_area, box_iou, generalized_box_iou
22
from .boxes import box_convert
3-
from .new_empty_tensor import _new_empty_tensor
43
from .deform_conv import deform_conv2d, DeformConv2d
54
from .roi_align import roi_align, RoIAlign
65
from .roi_pool import roi_pool, RoIPool
@@ -19,7 +18,7 @@
1918
'deform_conv2d', 'DeformConv2d', 'nms', 'batched_nms', 'remove_small_boxes',
2019
'clip_boxes_to_image', 'box_convert',
2120
'box_area', 'box_iou', 'generalized_box_iou', 'roi_align', 'RoIAlign', 'roi_pool',
22-
'RoIPool', '_new_empty_tensor', 'ps_roi_align', 'PSRoIAlign', 'ps_roi_pool',
21+
'RoIPool', 'ps_roi_align', 'PSRoIAlign', 'ps_roi_pool',
2322
'PSRoIPool', 'MultiScaleRoIAlign', 'FeaturePyramidNetwork',
2423
'sigmoid_focal_loss'
2524
]

torchvision/ops/_register_onnx_ops.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,7 @@ def roi_pool(g, input, rois, spatial_scale, pooled_height, pooled_width):
3838
pooled_shape_i=(pooled_height, pooled_width), spatial_scale_f=spatial_scale)
3939
return roi_pool, None
4040

41-
@parse_args('v', 'is')
42-
def new_empty_tensor_op(g, input, shape):
43-
dtype = input.type().scalarType()
44-
if dtype is None:
45-
dtype = 'Float'
46-
dtype = scalar_type_to_onnx.index(cast_pytorch_to_onnx[dtype])
47-
shape = g.op("Constant", value_t=torch.tensor(shape))
48-
return g.op("ConstantOfShape", shape,
49-
value_t=torch.tensor([0], dtype=scalar_type_to_pytorch_type[dtype]))
50-
5141
from torch.onnx import register_custom_op_symbolic
5242
register_custom_op_symbolic('torchvision::nms', symbolic_multi_label_nms, _onnx_opset_version)
5343
register_custom_op_symbolic('torchvision::roi_align', roi_align, _onnx_opset_version)
5444
register_custom_op_symbolic('torchvision::roi_pool', roi_pool, _onnx_opset_version)
55-
register_custom_op_symbolic('torchvision::_new_empty_tensor_op', new_empty_tensor_op, _onnx_opset_version)

torchvision/ops/new_empty_tensor.py

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

0 commit comments

Comments
 (0)