Skip to content

Commit

Permalink
[XPU] add xpu xhpc version info into version.show()
Browse files Browse the repository at this point in the history
  • Loading branch information
runzhech committed Dec 13, 2023
1 parent 329f449 commit 669c441
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
33 changes: 32 additions & 1 deletion python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -169,6 +178,7 @@ def show():
cudnn: '7.6.5'
xpu: '20230114'
xpu_xccl: '1.0.7'
xpu_xhpc: '20231208'
cinn: False
>>> # doctest: -SKIP

Expand All @@ -180,6 +190,7 @@ def show():
cudnn: '7.6.5'
xpu: '20230114'
xpu_xccl: '1.0.7'
xpu_xhpc: '20231208'
cinn: False
>>> # doctest: -SKIP

Expand All @@ -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():
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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@',
Expand Down
9 changes: 9 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 669c441

Please sign in to comment.