Update XNNPACK (#52645)

Summary:
This update contains the fix to XNNPACK by kimishpatel
Add unit test that exposed the problem
Updated torchvision checkout to 0.9.0rc1 hash

Fixes https://github.com/pytorch/pytorch/issues/52463

Pull Request resolved: https://github.com/pytorch/pytorch/pull/52645

Reviewed By: kimishpatel, seemethere

Differential Revision: D26598115

Pulled By: malfet

fbshipit-source-id: d652bacdee10bb975fc445ab227de37022b8ef51
This commit is contained in:
Nikita Shulga
2021-02-23 06:56:43 -08:00
committed by Facebook GitHub Bot
parent 64847c7f0b
commit 3721962c33
3 changed files with 21 additions and 2 deletions

View File

@ -10,6 +10,12 @@ from torch.nn import functional as F
from torch._C import MobileOptimizerType
from torch.testing._internal.common_quantized import override_quantized_engine
try:
import torchvision
HAS_TORCHVISION = True
except ImportError:
HAS_TORCHVISION = False
FileCheck = torch._C.FileCheck
class TestOptimizer(TestCase):
@ -428,6 +434,19 @@ class TestOptimizer(TestCase):
m_optim_res = m_optim(data)
torch.testing.assert_allclose(m_res, m_optim_res, rtol=1e-2, atol=1e-3)
@unittest.skipUnless(HAS_TORCHVISION, "Needs torchvision")
def test_mobilenet_optimize_for_mobile(self):
m = torchvision.models.mobilenet_v3_small()
m = torch.jit.script(m)
m = optimize_for_mobile(m)
# run forward 3 times until segfault, see https://github.com/pytorch/pytorch/issues/52463
x = torch.zeros(1, 3, 56, 56)
self.assertEqual(m(x).numel(), 1000)
self.assertEqual(m(x).numel(), 1000)
self.assertEqual(m(x).numel(), 1000)
if __name__ == '__main__':
run_tests()