(self)
| 30 | |
| 31 | class TestVerification(unittest.TestCase): |
| 32 | def test_constant_buffer(self) -> None: |
| 33 | def f(x: torch.Tensor) -> torch.Tensor: |
| 34 | return torch.ones(2) + x + torch.ones(2) |
| 35 | |
| 36 | # Generate program |
| 37 | program = ( |
| 38 | to_edge(export(WrapperModule(f), (torch.randn(2),), strict=True)) |
| 39 | .transform( |
| 40 | [ |
| 41 | ConstPropPass(), |
| 42 | ] |
| 43 | ) |
| 44 | .to_executorch() |
| 45 | ._emitter_output.program |
| 46 | ) |
| 47 | |
| 48 | test = Interpreter(program) |
| 49 | for val_idx in range(len(test.execution_plan.values)): |
| 50 | val = test.execution_plan.values[val_idx].val |
| 51 | if not ( |
| 52 | isinstance(val, Tensor) and val.data_buffer_idx == 0 |
| 53 | ) and not isinstance(val, TensorList): |
| 54 | test.load_value(val_idx) |
| 55 | vlist = test.get_value_list() |
| 56 | for e in vlist: |
| 57 | if isinstance(e, torch.Tensor): |
| 58 | self.assertTrue(torch.allclose(e, torch.ones(2))) |
| 59 | |
| 60 | # asserting only 2 constant Tensors exist in value list |
| 61 | self.assertEqual(len([e for e in vlist if isinstance(e, torch.Tensor)]), 2) |
| 62 | |
| 63 | def test_operator_list(self) -> None: |
| 64 | class Op1(torch.nn.Module): |
nothing calls this directly
no test coverage detected