From 669c441d0b5f05ee60aac9f04906b52a0ad50a24 Mon Sep 17 00:00:00 2001 From: runzhech Date: Wed, 13 Dec 2023 08:53:18 +0000 Subject: [PATCH] [XPU] add xpu xhpc version info into version.show() --- python/setup.py.in | 33 ++++++++++++++++++++++++++++++++- setup.py | 9 +++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/python/setup.py.in b/python/setup.py.in index f79cdc7ff028b0..38e58561baaa58 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -88,6 +88,12 @@ def get_xpu_xccl_version(): else: return 'False' +def get_xpu_xhpc_version(): + if '@WITH_XPU_XHPC@' == 'ON': + return '@XPU_XHPC_BASE_DATE@' + else: + return 'False' + def is_taged(): try: cmd = ['git', 'describe', '--exact-match', '--tags', 'HEAD', '2>/dev/null'] @@ -118,12 +124,13 @@ cuda_version = '%(cuda)s' cudnn_version = '%(cudnn)s' xpu_version = '%(xpu)s' xpu_xccl_version = '%(xpu_xccl)s' +xpu_xhpc_version = '%(xpu_xhpc)s' istaged = %(istaged)s commit = '%(commit)s' with_mkl = '%(with_mkl)s' cinn_version = '%(cinn)s' -__all__ = ['cuda', 'cudnn', 'show', 'xpu', 'xpu_xccl'] +__all__ = ['cuda', 'cudnn', 'show', 'xpu', 'xpu_xccl', 'xpu_xhpc'] def show(): """Get the version of paddle if `paddle` package if tagged. Otherwise, output the corresponding commit id. @@ -150,6 +157,8 @@ def show(): xpu_xccl: the xpu xccl version of package. It will return `False` if non-XPU version paddle package is installed + xpu_xhpc: the xpu xhpc version of package. It will return `False` if non-XPU version paddle package is installed + cinn: the cinn version of package. It will return `False` if paddle package is not compiled with CINN Examples: @@ -169,6 +178,7 @@ def show(): cudnn: '7.6.5' xpu: '20230114' xpu_xccl: '1.0.7' + xpu_xhpc: '20231208' cinn: False >>> # doctest: -SKIP @@ -180,6 +190,7 @@ def show(): cudnn: '7.6.5' xpu: '20230114' xpu_xccl: '1.0.7' + xpu_xhpc: '20231208' cinn: False >>> # doctest: -SKIP @@ -196,6 +207,7 @@ def show(): print('cudnn:', cudnn_version) print('xpu:', xpu_version) print('xpu_xccl:', xpu_xccl_version) + print('xpu_xhpc:', xpu_xhpc_version) print('cinn:', cinn_version) def mkl(): @@ -273,6 +285,24 @@ def xpu_xccl(): """ return xpu_xccl_version +def xpu_xhpc(): + """Get xpu xhpc version of paddle package. + + Returns: + string: Return the version information of xpu xhpc. If paddle package is non-XPU version, it will return False. + + Examples: + .. code-block:: python + + >>> import paddle + + >>> paddle.version.xpu_xhpc() + >>> # doctest: +SKIP('Different environments yield different output.') + '20231208' + + """ + return xpu_xhpc_version + def cinn(): """Get CINN version of paddle package. @@ -312,6 +342,7 @@ def cinn(): 'cudnn': get_cudnn_version(), 'xpu': get_xpu_version(), 'xpu_xccl': get_xpu_xccl_version(), + 'xpu_xhpc': get_xpu_xhpc_version(), 'commit': commit, 'istaged': is_taged(), 'with_mkl': '@WITH_MKL@', diff --git a/setup.py b/setup.py index 4bc720257c9356..34cca9481e5814 100644 --- a/setup.py +++ b/setup.py @@ -399,6 +399,14 @@ def get_xpu_xccl_version(): return 'False' +def get_xpu_xhpc_version(): + with_xpu_xhpc = env_dict.get("WITH_XPU_XHPC") + if with_xpu_xhpc == 'ON': + return env_dict.get("XPU_XHPC_BASE_DATE") + else: + return 'False' + + def is_taged(): try: cmd = [ @@ -640,6 +648,7 @@ def cinn(): 'cudnn': get_cudnn_version(), 'xpu': get_xpu_version(), 'xpu_xccl': get_xpu_xccl_version(), + 'xpu_xhpc': get_xpu_xhpc_version(), 'commit': commit, 'istaged': is_taged(), 'with_mkl': env_dict.get("WITH_MKL"),