From 6bc768965b87d5c737e141c15abdad06928d1098 Mon Sep 17 00:00:00 2001 From: Jacob Szwejbka Date: Mon, 21 Aug 2023 13:35:39 -0700 Subject: [PATCH] Move is_param and get_param out of exir and into export (#67) Summary: X-link: https://github.com/pytorch/pytorch/pull/107264 Pull Request resolved: https://github.com/pytorch/executorch/pull/67 These doesn't feel edge specific so moving out of exir. Reviewed By: tugsbayasgalan Differential Revision: D48361384 fbshipit-source-id: 4141a013934999ecd30add8c8bd2d5d6102fb46f --- exir/program/__init__.py | 4 ---- exir/program/_program.py | 22 ---------------------- 2 files changed, 26 deletions(-) diff --git a/exir/program/__init__.py b/exir/program/__init__.py index fb7f391b260..d50a88da8fe 100644 --- a/exir/program/__init__.py +++ b/exir/program/__init__.py @@ -11,8 +11,6 @@ edge_to_executorch_passes, ExecutorchProgram, ExirExportedProgram, - get_param, - is_param, multi_method_program_to_executorch, MultiMethodExecutorchProgram, MultiMethodExirExportedProgram, @@ -23,8 +21,6 @@ "ExecutorchProgram", "_to_edge", "edge_to_executorch_passes", - "is_param", - "get_param", "MultiMethodExirExportedProgram", "MultiMethodExecutorchProgram", "multi_method_program_to_executorch", diff --git a/exir/program/_program.py b/exir/program/_program.py index 94dfbc13df2..f53216e691e 100644 --- a/exir/program/_program.py +++ b/exir/program/_program.py @@ -203,28 +203,6 @@ def edge_to_executorch_passes(config: ExecutorchBackendConfig) -> List[PassType] return passes -def is_param(edge_program: ExportedProgram, node: torch.fx.Node) -> bool: - """ - Checks if the given node is a parameter within the edge_program - """ - return node.name in edge_program.graph_signature.inputs_to_parameters - - -def get_param( - edge_program: ExportedProgram, - node: torch.fx.Node, -) -> Optional[torch.nn.Parameter]: - """ - Returns the parameter associated with the given node in the edge program. - Returns None if the node is not a parameter within the edge_program - """ - if is_param(edge_program, node): - parameter_name = edge_program.graph_signature.inputs_to_parameters[node.name] - return edge_program.state_dict[parameter_name] - - return None - - ######## MULTI METHOD STUFF BELOW HERE. TO BE MERGED INTO ExirExportedProgram and ExecutorchProgram AND THEN DELETED ##########