Test FTMapBasic model through the modern torch.export API.
(self)
| 684 | )(self) |
| 685 | |
| 686 | def test_ft_map_basic(self): |
| 687 | """Test FTMapBasic model through the modern torch.export API.""" |
| 688 | from executorch.exir import EdgeCompileConfig, to_edge |
| 689 | |
| 690 | # Create model and get inputs |
| 691 | model = FTMapBasic() |
| 692 | inputs = model.get_random_inputs() |
| 693 | |
| 694 | # Export the model |
| 695 | exported_program = torch.export.export( |
| 696 | model, |
| 697 | inputs, |
| 698 | ) |
| 699 | |
| 700 | # Convert to edge program |
| 701 | edge_program = to_edge( |
| 702 | exported_program, |
| 703 | compile_config=EdgeCompileConfig(_check_ir_validity=False), |
| 704 | ) |
| 705 | |
| 706 | # Convert to executorch |
| 707 | executorch_program = edge_program.to_executorch() |
| 708 | |
| 709 | # Load and run |
| 710 | executorch_module = _load_for_executorch_from_buffer(executorch_program.buffer) |
| 711 | |
| 712 | # Test execution matches eager mode |
| 713 | eager_output = model(*inputs) |
| 714 | et_output = executorch_module.forward(list(inputs))[0] |
| 715 | |
| 716 | # Compare outputs |
| 717 | torch.testing.assert_close( |
| 718 | et_output, |
| 719 | eager_output, |
| 720 | rtol=1e-5, |
| 721 | atol=1e-8, |
| 722 | msg="ExecuTorch output doesn't match eager output", |
| 723 | ) |
| 724 | |
| 725 | @skipUnless(RUN_SKIPPED, "TODO(larryliu0820) Fix this in both fbcode and oss") |
| 726 | def test_ft_cond_dynshape(self): |
nothing calls this directly
no test coverage detected