diff --git a/caffe2/core/macros.h.in b/caffe2/core/macros.h.in index 9b05d629edec..5b971b1bbb27 100644 --- a/caffe2/core/macros.h.in +++ b/caffe2/core/macros.h.in @@ -29,7 +29,7 @@ #endif // Useful build settings that are recorded in the compiled binary -// torch.__build__.show() +// torch.__config__.show() #define CAFFE2_BUILD_STRINGS { \ {"TORCH_VERSION", "${TORCH_VERSION}"}, \ {"CXX_COMPILER", "${CMAKE_CXX_COMPILER}"}, \ @@ -65,4 +65,6 @@ {"USE_ITT", "${CAFFE2_USE_ITT}"}, \ {"USE_ROCM_KERNEL_ASSERT", "${USE_ROCM_KERNEL_ASSERT}"}, \ {"USE_CUSPARSELT", "${USE_CUSPARSELT}"}, \ + {"USE_XPU", "${USE_XPU}"}, \ + {"USE_XCCL", "${USE_XCCL}"}, \ } diff --git a/test/test_xpu.py b/test/test_xpu.py index aa91ce755308..b3bac2666d92 100644 --- a/test/test_xpu.py +++ b/test/test_xpu.py @@ -1,5 +1,6 @@ # Owner(s): ["module: intel"] +import re import subprocess import sys import tempfile @@ -732,6 +733,24 @@ class TestXPUAPISanity(TestCase): if not torch.xpu._is_compiled(): self.assertEqual(len(torch.xpu.get_arch_list()), 0) + def test_torch_config_for_xpu(self): + config = torch.__config__.show() + value = re.search(r"USE_XPU=([^,]+)", config) + self.assertIsNotNone(value) + if torch.xpu._is_compiled(): + self.assertTrue(value.group(1) in ["ON", "1"]) + value = re.search(r"USE_XCCL=([^,]+)", config) + if torch.distributed.is_xccl_available(): + self.assertTrue(value.group(1) in ["ON", "1"]) + else: + self.assertTrue(value.group(1) in ["OFF", "0"]) + else: + self.assertTrue(value.group(1) in ["OFF", "0"]) + self.assertFalse(torch.distributed.is_xccl_available()) + value = re.search(r"USE_XCCL=([^,]+)", config) + self.assertIsNotNone(value) + self.assertTrue(value.group(1) in ["OFF", "0"]) + if __name__ == "__main__": run_tests()