fix submodule imports by importing functions directly (#79368)

Summary:
fixes two sporadic issues from missing attributes:

- breaking circular imports
- submodule not being imported explicitly

Test Plan: sandcastle

Reviewed By: ehhuang

Differential Revision: D37071652

Pull Request resolved: https://github.com/pytorch/pytorch/pull/79368
Approved by: https://github.com/ananthsub
This commit is contained in:
Edward Wang (EcoF) 2022-06-22 08:01:23 +00:00 committed by PyTorch MergeBot
parent 7751ed41a6
commit ba4f780fde

View file

@ -6,7 +6,7 @@ import sys
import types
import torch.jit
import torch._utils_internal as torch_utils_internal
from torch import _utils_internal
# Query `hasattr` only once.
_SET_GLOBAL_FLAGS = hasattr(sys, 'getdlopenflags') and hasattr(sys, 'setdlopenflags')
@ -252,7 +252,7 @@ class _Ops(types.ModuleType):
if sys.executable == "torch_deploy":
return
path = torch_utils_internal.resolve_library_path(path)
path = _utils_internal.resolve_library_path(path)
with dl_open_guard():
# Import the shared library into the process, thus running its
# static (global) initialization code in order to register custom