MCPcopy Create free account
hub / github.com/pytorch/executorch / TestModel1

Class TestModel1

exir/tests/test_remove_view_copy.py:17–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17class TestModel1(nn.Module):
18 __test__ = False
19
20 def __init__(self):
21 super().__init__()
22 self.parameter = nn.Parameter(torch.rand(5, 6))
23 self.parameter.requires_grad = False
24 self.parameter2 = nn.Parameter(torch.rand(30))
25 self.parameter2.requires_grad = False
26
27 def forward(self, x):
28 v1 = self.parameter.view(
29 6, 5
30 ) # removed, lifetime of parameter will be extended
31 v2 = x.view(6, 5) # not removed
32 v3 = torch.ops.aten.mul.Tensor(v1, v2).view(
33 30
34 ) # removed, lifetime of mul.Tensor will be extended
35 v4 = torch.ops.aten.mul.Tensor(v3, self.parameter2)
36 v5 = v4.view(6, 5) # not removed, output of the graph
37 v6 = v4.view(2, 15) # not removed, output of the graph
38 return v5, v6
39
40 def get_example_inputs(self):
41 return (torch.rand(5, 6),)
42
43
44class TestRemoveViewCopy(unittest.TestCase):

Callers 3

test_disableMethod · 0.85
test_output_matchesMethod · 0.85
test_specMethod · 0.85

Calls

no outgoing calls

Tested by 3

test_disableMethod · 0.68
test_output_matchesMethod · 0.68
test_specMethod · 0.68