mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
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:
committed by
Facebook GitHub Bot
parent
14d604a13e
commit
eab18a9a40
@ -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):
|
||||
|
||||
Reference in New Issue
Block a user