mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Summary: (Also, exposed the macros that we use during build time via the macros.h header file) Closes https://github.com/caffe2/caffe2/pull/233 Differential Revision: D4803311 Pulled By: Yangqing fbshipit-source-id: 9f8ce57692f81f7a8994344846d3c90aa2c7070a
24 lines
604 B
Python
24 lines
604 B
Python
## @package extension_loader
|
|
# Module caffe2.python.extension_loader
|
|
from __future__ import absolute_import
|
|
from __future__ import division
|
|
from __future__ import print_function
|
|
from __future__ import unicode_literals
|
|
import contextlib
|
|
import ctypes
|
|
import sys
|
|
|
|
|
|
_set_global_flags = (
|
|
hasattr(sys, 'getdlopenflags') and hasattr(sys, 'setdlopenflags'))
|
|
|
|
|
|
@contextlib.contextmanager
|
|
def DlopenGuard():
|
|
if _set_global_flags:
|
|
old_flags = sys.getdlopenflags()
|
|
sys.setdlopenflags(old_flags | ctypes.RTLD_GLOBAL)
|
|
yield
|
|
if _set_global_flags:
|
|
sys.setdlopenflags(old_flags)
|