mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add support for C++ frontend wrapper on Linux (#69094)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/69094 Partially addresses https://github.com/pytorch/pytorch/issues/68768 Test Plan: Imported from OSS Reviewed By: seemethere Differential Revision: D32730079 Pulled By: malfet fbshipit-source-id: 854e4215ff66e087bdf354fed7a17e87f2649c87
This commit is contained in:
committed by
Facebook GitHub Bot
parent
33c3c539b6
commit
bede18b061
@ -864,5 +864,13 @@ class TestExtensionUtils(TestCase):
|
||||
torch._register_device_module('xpu', DummyXPUModule)
|
||||
|
||||
|
||||
class TestCppExtensionUtils(TestCase):
|
||||
def test_cpp_compiler_is_ok(self):
|
||||
self.assertTrue(torch.utils.cpp_extension.check_compiler_ok_for_platform('c++'))
|
||||
|
||||
def test_cc_compiler_is_ok(self):
|
||||
self.assertTrue(torch.utils.cpp_extension.check_compiler_ok_for_platform('cc'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run_tests()
|
||||
|
@ -260,15 +260,18 @@ def check_compiler_ok_for_platform(compiler: str) -> bool:
|
||||
# Check the compiler name
|
||||
if any(name in compiler_path for name in _accepted_compilers_for_platform()):
|
||||
return True
|
||||
# If ccache is used the compiler path is /usr/bin/ccache. Check by -v flag.
|
||||
# If compiler wrapper is used try to infer the actual compiler by invoking it with -v flag
|
||||
version_string = subprocess.check_output([compiler, '-v'], stderr=subprocess.STDOUT).decode(*SUBPROCESS_DECODE_ARGS)
|
||||
if IS_LINUX:
|
||||
# Check for 'gcc' or 'g++'
|
||||
# Check for 'gcc' or 'g++' for sccache warpper
|
||||
pattern = re.compile("^COLLECT_GCC=(.*)$", re.MULTILINE)
|
||||
results = re.findall(pattern, version_string)
|
||||
if len(results) != 1:
|
||||
return False
|
||||
compiler_path = os.path.realpath(results[0].strip())
|
||||
# On RHEL/CentOS c++ is a gcc compiler wrapper
|
||||
if os.path.basename(compiler_path) == 'c++' and 'gcc version' in version_string:
|
||||
return True
|
||||
return any(name in compiler_path for name in _accepted_compilers_for_platform())
|
||||
if IS_MACOS:
|
||||
# Check for 'clang' or 'clang++'
|
||||
|
Reference in New Issue
Block a user