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

Method get_example_input

export/export.py:589–614  ·  view source on GitHub ↗

Get the example input for a specific method. Args: method_name: Name of the method to get example input for, defaults to "forward" Returns: Tuple of tensors representing the example input Raises: KeyError: If the method name is

(
        self, method_name: str = "forward"
    )

Source from the content-addressed store, hash-verified

587 save_pte_program(self.get_executorch_program_manager(), output_name)
588
589 def get_example_input(
590 self, method_name: str = "forward"
591 ) -> Tuple[torch.Tensor, ...]:
592 """
593 Get the example input for a specific method.
594
595 Args:
596 method_name: Name of the method to get example input for, defaults to "forward"
597
598 Returns:
599 Tuple of tensors representing the example input
600
601 Raises:
602 KeyError: If the method name is not found in example inputs
603 ValueError: If the example inputs list is empty
604 """
605 if method_name not in self._example_inputs:
606 raise KeyError(f"Method name '{method_name}' not found in example inputs")
607
608 # Access the first element of the list for this method
609 example_inputs_list = self._example_inputs[method_name]
610 if not example_inputs_list:
611 raise ValueError(f"Example inputs list for method {method_name} is empty")
612
613 # The original code expects this to be a tuple of tensors
614 return self._example_inputs[method_name][0]
615
616 def run_method(
617 self,

Calls

no outgoing calls