Add aten::to NNAPI converter (#58540)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/58540

Add support for aten::to op in the NNAPI model converter for simple
cases like to("cpu"), to("gpu")

Test Plan: pytest test/test_nnapi.py::TestNNAPI::test_to

Reviewed By: anshuljain1

Differential Revision: D28531941

fbshipit-source-id: 0c934f7aceaff2669307c3426efe32046d8c44f3
This commit is contained in:
Akshit Khurana
2021-07-07 12:37:51 -07:00
committed by Facebook GitHub Bot
parent 14d604a13e
commit eab18a9a40
2 changed files with 31 additions and 0 deletions

View File

@ -238,6 +238,26 @@ class TestNNAPI(TestCase):
convert_args=[torch.zeros(0, 0)],
)
def test_to(self):
class ToCPU(torch.nn.Module):
def __init__(self):
super().__init__()
self.prelu = torch.nn.PReLU()
def forward(self, x):
y = x.to("cpu")
# add prelu since input operand can't be output
return self.prelu(y)
arg = torch.randn(1, 2, 3, 3)
self.check(ToCPU(), arg)
# Test flexible size
self.check(
ToCPU(),
arg,
convert_args=[torch.zeros(1, 2, 0, 0)],
)
def test_mean(self):
class MeanModule(torch.nn.Module):
def __init__(self, dim, keep=False):