Create a bundled program containing the model and test cases for correctness testing. Args: executorch_program: The ExecutorchProgramManager to bundle sample_inputs: Sample inputs for the model expected_outputs: Expected outputs from running the model with sample_in
(
executorch_program: ExecutorchProgramManager,
sample_inputs: Tuple[torch.Tensor, ...],
expected_outputs: List[Any],
method_name: str = "forward",
)
| 672 | |
| 673 | |
| 674 | def create_bundled_program( |
| 675 | executorch_program: ExecutorchProgramManager, |
| 676 | sample_inputs: Tuple[torch.Tensor, ...], |
| 677 | expected_outputs: List[Any], |
| 678 | method_name: str = "forward", |
| 679 | ) -> bytes: |
| 680 | """ |
| 681 | Create a bundled program containing the model and test cases for correctness testing. |
| 682 | |
| 683 | Args: |
| 684 | executorch_program: The ExecutorchProgramManager to bundle |
| 685 | sample_inputs: Sample inputs for the model |
| 686 | expected_outputs: Expected outputs from running the model with sample_inputs |
| 687 | method_name: Name of the method to test (default: "forward") |
| 688 | |
| 689 | Returns: |
| 690 | Serialized bundled program as bytes |
| 691 | """ |
| 692 | # Flatten sample inputs to match expected format |
| 693 | inputs_flattened, _ = tree_flatten(sample_inputs) |
| 694 | |
| 695 | # Create test suite with the sample inputs and expected outputs |
| 696 | test_suites = [ |
| 697 | MethodTestSuite( |
| 698 | method_name=method_name, |
| 699 | test_cases=[ |
| 700 | MethodTestCase( |
| 701 | inputs=inputs_flattened, |
| 702 | expected_outputs=expected_outputs, |
| 703 | ) |
| 704 | ], |
| 705 | ) |
| 706 | ] |
| 707 | |
| 708 | # Create bundled program |
| 709 | bundled_program = BundledProgram(executorch_program, test_suites) |
| 710 | |
| 711 | # Serialize to flatbuffer |
| 712 | bundled_buffer = serialize_from_bundled_program_to_flatbuffer(bundled_program) |
| 713 | |
| 714 | return bundled_buffer |
| 715 | |
| 716 | |
| 717 | def save_bundled_program( |
no test coverage detected