Revert D35124731: Automatically extern C extension modules in torch.package

Test Plan: revert-hammer

Differential Revision:
D35124731 (0f27b4b7fc)

Original commit changeset: a4b7fdf3210e

Original Phabricator Diff: D35124731 (0f27b4b7fc)

fbshipit-source-id: ee598f18d43ea1becb6f2673c7ae309e4b4dda35
(cherry picked from commit 6248897d18f4f02f0ad7353c4b78f1cbb12250ae)
This commit is contained in:
Jane Xu
2022-03-28 13:20:27 -07:00
committed by PyTorch MergeBot
parent 0428364cbf
commit 58f78ff4e0
2 changed files with 1 additions and 47 deletions

View File

@ -187,7 +187,6 @@ class PackageExporter:
self,
f: Union[str, Path, BinaryIO],
importer: Union[Importer, Sequence[Importer]] = sys_importer,
auto_extern_c_extension_modules: bool = False,
):
"""
Create an exporter.
@ -197,8 +196,6 @@ class PackageExporter:
or a binary I/O object.
importer: If a single Importer is passed, use that to search for modules.
If a sequence of importers are passsed, an ``OrderedImporter`` will be constructed out of them.
auto_extern_c_extension_modules: Flag whether to enable autoly extern c extension modules (``True``),
or disable (``False``).
"""
if isinstance(f, (Path, str)):
f = str(f)
@ -212,8 +209,6 @@ class PackageExporter:
self.serialized_reduces: Dict[int, Any] = {}
self.auto_extern_c_extension_modules = auto_extern_c_extension_modules
# A graph tracking all the modules and pickle objects added to this
# package and the dependencies between them.
# - Each node is a module name (or a pickle name that looks like '<foo.obj.pkl>')
@ -533,17 +528,7 @@ class PackageExporter:
if filename is None:
packaging_error = PackagingErrorReason.NO_DUNDER_FILE
elif filename.endswith(tuple(importlib.machinery.EXTENSION_SUFFIXES)):
if self.auto_extern_c_extension_modules:
self.extern([module_name])
self.dependency_graph.add_node(
module_name,
action=_ModuleProviderAction.EXTERN,
is_package=is_package,
provided=True,
)
return
else:
packaging_error = PackagingErrorReason.IS_EXTENSION_MODULE
packaging_error = PackagingErrorReason.IS_EXTENSION_MODULE
else:
packaging_error = PackagingErrorReason.SOURCE_FILE_NOT_FOUND
error_context = f"filename: {filename}"