5 from itertools
import chain
8 IS_WINDOWS = (platform.system() ==
'Windows')
9 IS_DARWIN = (platform.system() ==
'Darwin')
10 IS_LINUX = (platform.system() ==
'Linux')
11 IS_PPC = (platform.machine() ==
'ppc64le')
12 IS_ARM = (platform.machine() ==
'aarch64')
14 IS_CONDA =
'conda' in sys.version
or 'Continuum' in sys.version
or any([x.startswith(
'CONDA')
for x
in os.environ])
15 CONDA_DIR = os.path.join(os.path.dirname(sys.executable),
'..')
17 IS_64BIT = (struct.calcsize(
"P") == 8)
20 def check_env_flag(name, default=''):
21 return os.getenv(name, default).upper()
in [
'ON',
'1',
'YES',
'TRUE',
'Y']
24 def check_negative_env_flag(name, default=''):
25 return os.getenv(name, default).upper()
in [
'OFF',
'0',
'NO',
'FALSE',
'N']
28 def gather_paths(env_vars):
29 return list(chain(*(os.getenv(v,
'').
split(os.pathsep)
for v
in env_vars)))
32 def lib_paths_from_base(base_path):
33 return [os.path.join(base_path, s)
for s
in [
'lib/x64',
'lib',
'lib64']]
36 def hotpatch_var(var, prefix='USE_'):
37 if check_env_flag(
'NO_' + var):
38 os.environ[prefix + var] =
'0' 39 elif check_negative_env_flag(
'NO_' + var):
40 os.environ[prefix + var] =
'1' 41 elif check_env_flag(
'WITH_' + var):
42 os.environ[prefix + var] =
'1' 43 elif check_negative_env_flag(
'WITH_' + var):
44 os.environ[prefix + var] =
'0' 47 def hotpatch_build_env_vars():
50 use_env_vars = [
'CUDA',
'CUDNN',
'FBGEMM',
'MIOPEN',
'MKLDNN',
'NNPACK',
'DISTRIBUTED',
51 'OPENCV',
'TENSORRT',
'QNNPACK',
'FFMPEG',
'SYSTEM_NCCL',
53 list(map(hotpatch_var, use_env_vars))
56 build_env_vars = [
'BINARY',
'TEST',
'CAFFE2_OPS']
57 [hotpatch_var(v,
'BUILD_')
for v
in build_env_vars]
59 hotpatch_build_env_vars()
61 DEBUG = check_env_flag(
'DEBUG')
62 REL_WITH_DEB_INFO = check_env_flag(
'REL_WITH_DEB_INFO')
63 USE_MKLDNN = check_env_flag(
'USE_MKLDNN',
'OFF' if IS_PPC
or IS_ARM
else 'ON')
Module caffe2.python.layers.split.