mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add quantized::convtranspose2d (#63914)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63914 Test Plan: Imported from OSS Reviewed By: dreiss Differential Revision: D30531889 fbshipit-source-id: a65e389da2722efbc62e3fe1edf503732326350d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ab5eb56983
commit
1de8976e85
@ -540,13 +540,14 @@ class TestNNAPI(TestCase):
|
||||
)
|
||||
|
||||
def test_conv2d_transpose(self):
|
||||
torch.manual_seed(29)
|
||||
in_ch, out_ch, kernel = (5, 7, (2, 2))
|
||||
input_dim = (4, 5, 3, 3)
|
||||
inp = torch.randn(input_dim)
|
||||
convert_dims = input_dim[:2] + (0, 0)
|
||||
|
||||
for kind in ["float", "float-nhwc", "quant", "quant-nhwc"]:
|
||||
with self.subTest(kind):
|
||||
inp = torch.randn(input_dim)
|
||||
model = torch.nn.ConvTranspose2d(in_ch, out_ch, kernel)
|
||||
output_size = model(inp).numel()
|
||||
atol_rtol = (0.0002, 0)
|
||||
@ -554,20 +555,14 @@ class TestNNAPI(TestCase):
|
||||
convert_arg = torch.zeros(*convert_dims)
|
||||
|
||||
if "quant" in kind:
|
||||
# FIXME 'aten::slow_conv_transpose2d' with arguments from the 'QuantizedCPU' backend
|
||||
continue
|
||||
model = torch.nn.Sequential(model)
|
||||
model.eval()
|
||||
model = torch.nn.quantized.ConvTranspose2d(in_ch, out_ch, kernel)
|
||||
model.qconfig = torch.quantization.get_default_qconfig('qnnpack')
|
||||
model = torch.quantization.prepare(model)
|
||||
model(inp)
|
||||
model = torch.quantization.convert(model)
|
||||
inp = qpt(inp, 1.0 / 16, 128)
|
||||
# I've seen numerical differences between QNNPACK and NNAPI,
|
||||
# but never more than 1 quantum, and never more than ~1% of
|
||||
# but never more than 1 quantum, and never more than ~10% of
|
||||
# the output in this test.
|
||||
atol_rtol = (1, 0)
|
||||
limit = output_size * 0.03
|
||||
limit = output_size * 0.1
|
||||
convert_arg = qpt(convert_arg, 1.0 / 16, 128)
|
||||
|
||||
if "nhwc" in kind:
|
||||
|
Reference in New Issue
Block a user