Override the resolve_library_path in FBCode (#17497)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17497

The following problems have been addressed: 1) import torch.ops correctly, 2) make realpath call optional

Reviewed By: dzhulgakov

Differential Revision: D14094358

fbshipit-source-id: 2f9a6fca656867287a7c82c465a4554384ff7323
This commit is contained in:
Lu Fang
2019-03-12 22:06:25 -07:00
committed by Facebook Github Bot
parent b21e9e4dae
commit 8bc3b66be9
2 changed files with 6 additions and 2 deletions

View File

@ -4,9 +4,9 @@ import contextlib
import ctypes
import sys
import types
import os.path
import torch.jit
import torch._utils_internal
# Query `hasattr` only once.
_SET_GLOBAL_FLAGS = hasattr(sys, 'getdlopenflags') and hasattr(sys, 'setdlopenflags')
@ -94,7 +94,7 @@ class _Ops(types.ModuleType):
Arguments:
path (str): A path to a shared library to load.
"""
path = os.path.realpath(path)
path = torch._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

View File

@ -29,5 +29,9 @@ def prepare_multiprocessing_environment(path):
pass
def resolve_library_path(path):
return os.path.realpath(path)
TEST_MASTER_ADDR = '127.0.0.1'
TEST_MASTER_PORT = 29500