Skip to content

Commit

Permalink
Remove _new_empty_tensor. (#3156)
Browse files Browse the repository at this point in the history
Co-authored-by: Francisco Massa <[email protected]>
  • Loading branch information
datumbox and fmassa authored Dec 11, 2020
1 parent e337103 commit 07a9c95
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 110 deletions.
14 changes: 0 additions & 14 deletions test/test_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,6 @@ def to_numpy(tensor):
else:
raise

@unittest.skip("Disable test until Split w/ zero sizes is implemented in ORT")
def test_new_empty_tensor(self):
class Module(torch.nn.Module):
def __init__(self):
super(Module, self).__init__()
self.conv2 = ops.misc.ConvTranspose2d(16, 33, (3, 5))

def forward(self, input2):
return self.conv2(input2)

input = torch.rand(0, 16, 10, 10)
test_input = torch.rand(0, 16, 20, 20)
self.run_model(Module(), [(input, ), (test_input,)], do_constant_folding=False)

def test_nms(self):
boxes = torch.rand(5, 4)
boxes[:, 2:] += torch.rand(5, 2)
Expand Down
9 changes: 0 additions & 9 deletions test/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,6 @@ def test_autocast(self):
self.test_nms_cuda(dtype=dtype)


class NewEmptyTensorTester(unittest.TestCase):
def test_new_empty_tensor(self):
input = torch.tensor([2., 2.], requires_grad=True)
new_shape = [3, 3]
out = torch.ops.torchvision._new_empty_tensor_op(input, new_shape)
assert out.size() == torch.Size([3, 3])
assert out.dtype == input.dtype


class DeformConvTester(OpTester, unittest.TestCase):
def expected_fn(self, x, weight, offset, mask, bias, stride=1, padding=0, dilation=1):
stride_h, stride_w = _pair(stride)
Expand Down
45 changes: 0 additions & 45 deletions torchvision/csrc/ops/new_empty_tensor_op.cpp

This file was deleted.

14 changes: 0 additions & 14 deletions torchvision/csrc/ops/new_empty_tensor_op.h

This file was deleted.

3 changes: 1 addition & 2 deletions torchvision/ops/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .boxes import nms, batched_nms, remove_small_boxes, clip_boxes_to_image, box_area, box_iou, generalized_box_iou
from .boxes import box_convert
from .new_empty_tensor import _new_empty_tensor
from .deform_conv import deform_conv2d, DeformConv2d
from .roi_align import roi_align, RoIAlign
from .roi_pool import roi_pool, RoIPool
Expand All @@ -19,7 +18,7 @@
'deform_conv2d', 'DeformConv2d', 'nms', 'batched_nms', 'remove_small_boxes',
'clip_boxes_to_image', 'box_convert',
'box_area', 'box_iou', 'generalized_box_iou', 'roi_align', 'RoIAlign', 'roi_pool',
'RoIPool', '_new_empty_tensor', 'ps_roi_align', 'PSRoIAlign', 'ps_roi_pool',
'RoIPool', 'ps_roi_align', 'PSRoIAlign', 'ps_roi_pool',
'PSRoIPool', 'MultiScaleRoIAlign', 'FeaturePyramidNetwork',
'sigmoid_focal_loss'
]
11 changes: 0 additions & 11 deletions torchvision/ops/_register_onnx_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,7 @@ def roi_pool(g, input, rois, spatial_scale, pooled_height, pooled_width):
pooled_shape_i=(pooled_height, pooled_width), spatial_scale_f=spatial_scale)
return roi_pool, None

@parse_args('v', 'is')
def new_empty_tensor_op(g, input, shape):
dtype = input.type().scalarType()
if dtype is None:
dtype = 'Float'
dtype = scalar_type_to_onnx.index(cast_pytorch_to_onnx[dtype])
shape = g.op("Constant", value_t=torch.tensor(shape))
return g.op("ConstantOfShape", shape,
value_t=torch.tensor([0], dtype=scalar_type_to_pytorch_type[dtype]))

from torch.onnx import register_custom_op_symbolic
register_custom_op_symbolic('torchvision::nms', symbolic_multi_label_nms, _onnx_opset_version)
register_custom_op_symbolic('torchvision::roi_align', roi_align, _onnx_opset_version)
register_custom_op_symbolic('torchvision::roi_pool', roi_pool, _onnx_opset_version)
register_custom_op_symbolic('torchvision::_new_empty_tensor_op', new_empty_tensor_op, _onnx_opset_version)
15 changes: 0 additions & 15 deletions torchvision/ops/new_empty_tensor.py

This file was deleted.

0 comments on commit 07a9c95

Please sign in to comment.