Test FTMapDynShape model through the modern torch.export API. Note: The higher-order map operation specializes on the iteration dimension at export time, so varying batch sizes are not supported. This test verifies that the map-based model can be exported and executed correc
(self)
| 729 | )(self) |
| 730 | |
| 731 | def test_ft_map_dynshape(self): |
| 732 | """Test FTMapDynShape model through the modern torch.export API. |
| 733 | |
| 734 | Note: The higher-order map operation specializes on the iteration dimension |
| 735 | at export time, so varying batch sizes are not supported. This test verifies |
| 736 | that the map-based model can be exported and executed correctly through the |
| 737 | ExecuTorch pipeline using the modern torch.export.export() API. |
| 738 | """ |
| 739 | from executorch.exir import EdgeCompileConfig, to_edge |
| 740 | |
| 741 | # Create model and get inputs |
| 742 | model = FTMapDynShape() |
| 743 | # Use upper bound inputs since map specializes on the iteration dimension |
| 744 | inputs = model.get_upper_bound_inputs() |
| 745 | |
| 746 | # Export the model |
| 747 | exported_program = torch.export.export( |
| 748 | model, |
| 749 | inputs, |
| 750 | ) |
| 751 | |
| 752 | # Convert to edge program |
| 753 | edge_program = to_edge( |
| 754 | exported_program, |
| 755 | compile_config=EdgeCompileConfig(_check_ir_validity=False), |
| 756 | ) |
| 757 | |
| 758 | # Convert to executorch |
| 759 | executorch_program = edge_program.to_executorch() |
| 760 | |
| 761 | # Load and run |
| 762 | executorch_module = _load_for_executorch_from_buffer(executorch_program.buffer) |
| 763 | |
| 764 | # Test execution matches eager mode |
| 765 | eager_output = model(*inputs) |
| 766 | et_output = executorch_module.forward(list(inputs))[0] |
| 767 | |
| 768 | # Compare outputs |
| 769 | torch.testing.assert_close( |
| 770 | et_output, |
| 771 | eager_output, |
| 772 | rtol=1e-5, |
| 773 | atol=1e-8, |
| 774 | msg="ExecuTorch output doesn't match eager output", |
| 775 | ) |
| 776 | |
| 777 | @skipUnless(RUN_SKIPPED, "TODO(larryliu0820) Fix this in both fbcode and oss") |
| 778 | def test_batch_norm(self): |
nothing calls this directly
no test coverage detected