mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[BE] Remove __reduce_deploy__ (#158291)
This PR removes the integration point torch.fx had with torch::deploy (and another minor change). Note: This PR has some broken mypy errors, but I believe those should have been in the code base beforehand, and should be fixed in a separate PR Pull Request resolved: https://github.com/pytorch/pytorch/pull/158291 Approved by: https://github.com/albanD ghstack dependencies: #158290
This commit is contained in:
@ -1062,7 +1062,6 @@ coverage_ignore_functions = [
|
||||
"z3op",
|
||||
"z3str",
|
||||
# torch.fx.graph_module
|
||||
"reduce_deploy_graph_module",
|
||||
"reduce_graph_module",
|
||||
"reduce_package_graph_module",
|
||||
# torch.fx.node
|
||||
|
@ -29,7 +29,6 @@ torch.fx.graph_module.GraphModule.add_submodule(self, target: str, m: torch.nn.m
|
||||
torch.fx.graph_module.GraphModule.delete_all_unused_submodules(self) -> None
|
||||
torch.fx.graph_module.GraphModule.delete_submodule(self, target: str) -> bool
|
||||
torch.fx.graph_module.GraphModule.recompile(self) -> torch.fx.graph.PythonCode
|
||||
torch.fx.graph_module.reduce_deploy_graph_module(importer: Callable, body: Dict[Any, Any], import_block: str) -> torch.nn.modules.module.Module
|
||||
torch.fx.graph_module.reduce_graph_module(body: Dict[Any, Any], import_block: str) -> torch.nn.modules.module.Module
|
||||
torch.fx.graph_module.reduce_package_graph_module(importer: Callable, body: Dict[Any, Any], generated_module_name: str) -> torch.nn.modules.module.Module
|
||||
torch.fx.interpreter.Interpreter.__init__(self, module: torch.nn.modules.module.Module, garbage_collect_values: bool = True, graph: Optional[torch.fx.graph.Graph] = None)
|
||||
|
@ -3474,7 +3474,6 @@ MOD_SKIPLIST = [
|
||||
"torch._custom_op",
|
||||
"torch._custom_ops",
|
||||
"torch._decomp",
|
||||
"torch._deploy",
|
||||
"torch._dispatch",
|
||||
"torch._dynamo",
|
||||
"torch._export",
|
||||
|
@ -127,11 +127,6 @@ class _LazyGraphModule(GraphModule):
|
||||
|
||||
forward = _lazy_forward
|
||||
|
||||
# TODO: we should handle __reduce_deploy__ the same way as __reduce_package__,
|
||||
# or __reduce__ by calling _real_recompile. But I don't find a good way
|
||||
# to test __reduce_deploy__ out. Also it's very unlikely that LazyGraphModule
|
||||
# will be used in torch::deploy. So it's skipped for now.
|
||||
|
||||
def __reduce_package__(self, exporter: PackageExporter):
|
||||
"""
|
||||
Follow GraphModule.__reduce__ but call 'self._real_recompile' rather
|
||||
|
@ -30,7 +30,6 @@ from .graph import (
|
||||
__all__ = [
|
||||
"reduce_graph_module",
|
||||
"reduce_package_graph_module",
|
||||
"reduce_deploy_graph_module",
|
||||
"GraphModule",
|
||||
]
|
||||
|
||||
@ -147,18 +146,6 @@ def reduce_package_graph_module(
|
||||
return _deserialize_graph_module(forward, body)
|
||||
|
||||
|
||||
@compatibility(is_backward_compatible=True)
|
||||
def reduce_deploy_graph_module(
|
||||
importer: PackageImporter, body: dict[Any, Any], import_block: str
|
||||
) -> torch.nn.Module:
|
||||
ns = {}
|
||||
ns["__builtins__"] = importer.patched_builtins
|
||||
fn_src = body.get("_code")
|
||||
assert fn_src is not None
|
||||
forward = _forward_from_src(import_block + fn_src, ns)
|
||||
return _deserialize_graph_module(forward, body)
|
||||
|
||||
|
||||
# We create a dummy class here because symbolic_trace pulls the forward()
|
||||
# function off of the class, rather than the instance. This class is used
|
||||
# in _deserialize_graph_module() below.
|
||||
@ -855,14 +842,6 @@ class {module_name}(torch.nn.Module):
|
||||
|
||||
# Passing Tracer as argument allows subclasses extending fx.GraphModule
|
||||
# define their own Tracer (extending fx.Tracer).
|
||||
def __reduce_deploy__(self, importer: Importer):
|
||||
dict_without_graph = self.__dict__.copy()
|
||||
dict_without_graph["_graphmodule_cls_name"] = self.__class__.__name__
|
||||
del dict_without_graph["_graph"]
|
||||
|
||||
python_code = self.recompile()
|
||||
import_block = _format_import_block(python_code.globals, importer)
|
||||
return (reduce_deploy_graph_module, (dict_without_graph, import_block))
|
||||
|
||||
def __reduce_package__(self, exporter: PackageExporter):
|
||||
dict_without_graph = self.__dict__.copy()
|
||||
|
Reference in New Issue
Block a user