Skip to content

Commit

Permalink
add implementation to call SLEEF transcendental functions
Browse files Browse the repository at this point in the history
  • Loading branch information
yamadafuyuka authored and kawakami-k committed Apr 17, 2023
1 parent ef087cb commit 87b59b3
Show file tree
Hide file tree
Showing 9 changed files with 704 additions and 2,979 deletions.
3 changes: 2 additions & 1 deletion mkl_umath/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) 2019-2021, Intel Corporation
# Copyright 2023 FUJITSU LIMITED
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand All @@ -24,7 +25,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

'''
Implementation of Numpy universal math functions using Intel(R) MKL and Intel(R) C compiler runtime.
Implementation of Numpy universal math functions using SLEEF.
'''

from ._version import __version__
Expand Down
2 changes: 1 addition & 1 deletion mkl_umath/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.1'
__version__ = '0.0.1'
288 changes: 3 additions & 285 deletions mkl_umath/generate_umath.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) 2019-2021, Intel Corporation
# Copyright 2023 FUJITSU LIMITED
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand All @@ -25,9 +26,9 @@

# Adapted from numpy/core/code_generators/generate_umath.py

# Content of https://github.com/numpy/numpy/commit/62b82961e12cc13379fb67f03c71062f94285cd1
# Content of https://github.com/numpy/numpy/commit/c1ffdbc0c29d48ece717acb5bfbf811c935b41f6
#
# Copyright (c) 2005-2021, NumPy Developers.
# Copyright (c) 2005-2023, NumPy Developers.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -325,183 +326,6 @@ def english_upper(s):
# an object which expands a list of character codes into an array of
# TypeDescriptions.
defdict = {
'add':
Ufunc(2, 1, Zero,
docstrings.get('numpy.core.umath.add'),
None,
TD(inexactvec + cmplxvec),
),
'subtract':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.subtract'),
None,
TD(inexactvec + cmplxvec),
),
'multiply':
Ufunc(2, 1, One,
docstrings.get('numpy.core.umath.multiply'),
None,
TD(inexactvec + cmplxvec),
),
'floor_divide':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.floor_divide'),
None,
TD(inexactvec + cmplxvec),
),
'true_divide':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.true_divide'),
None,
TD(inexactvec + cmplxvec),
),
'conjugate':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.conjugate'),
None,
TD(inexactvec + cmplxvec),
),
# 'fmod':
'square':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.square'),
None,
TD(inexactvec + cmplxvec),
),
'reciprocal':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.reciprocal'),
None,
TD(inexactvec + cmplxvec),
),
# '_ones_like':
# 'power':
# 'float_power':
'absolute':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.absolute'),
None,
TD(inexactvec),
TD('F', out='f'),
TD('D', out='d'),
),
# '_arg':
'negative':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.negative'),
None,
TD(inexactvec),
),
'positive':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.positive'),
None,
TD(inexactvec),
),
'sign':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.sign'),
None,
TD(inexactvec + cmplxvec),
),
'greater':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.greater'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'greater_equal':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.greater_equal'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'less':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.less'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'less_equal':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.less_equal'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'equal':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.equal'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'not_equal':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.not_equal'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'logical_and':
Ufunc(2, 1, True_,
docstrings.get('numpy.core.umath.logical_and'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'logical_not':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.logical_not'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'logical_or':
Ufunc(2, 1, False_,
docstrings.get('numpy.core.umath.logical_or'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'logical_xor':
Ufunc(2, 1, False_,
docstrings.get('numpy.core.umath.logical_xor'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'maximum':
Ufunc(2, 1, ReorderableNone,
docstrings.get('numpy.core.umath.maximum'),
None,
TD(inexactvec + cmplxvec),
),
'minimum':
Ufunc(2, 1, ReorderableNone,
docstrings.get('numpy.core.umath.minimum'),
None,
TD(inexactvec + cmplxvec),
),
# 'clip':
'fmax':
Ufunc(2, 1, ReorderableNone,
docstrings.get('numpy.core.umath.fmax'),
None,
TD(inexactvec + cmplxvec),
),
'fmin':
Ufunc(2, 1, ReorderableNone,
docstrings.get('numpy.core.umath.fmin'),
None,
TD(inexactvec + cmplxvec),
),
# 'logaddexp':
# 'logaddexp2':
# 'bitwise_and':
# 'bitwise_or':
# 'bitwise_xor':
# 'invert':
# 'left_shift':
# 'right_shift':
# 'heaviside':
# 'degrees':
# 'rad2deg':
# 'radians':
# 'deg2rad':
'arccos':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.arccos'),
Expand Down Expand Up @@ -628,112 +452,6 @@ def english_upper(s):
None,
TD(inexactvec),
),
'ceil':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.ceil'),
None,
TD(inexactvec),
),
'trunc':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.trunc'),
None,
TD(inexactvec),
),
'fabs':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.fabs'),
None,
TD(inexactvec),
),
'floor':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.floor'),
None,
TD(inexactvec),
),
'rint':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.rint'),
None,
TD(inexactvec),
),
# 'arctan2':
'remainder':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.remainder'),
None,
TD(inexactvec),
),
# 'divmod':
# 'hypot':
'isnan':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.isnan'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
# 'isnat':
'isinf':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.isinf'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
'isfinite':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.isfinite'),
None,
TD(inexactvec + cmplxvec, out='?'),
),
# 'signbit':
'copysign':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.copysign'),
None,
TD(inexactvec),
),
'nextafter':
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.nextafter'),
None,
TD(inexactvec),
),
'spacing':
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.spacing'),
None,
TD(inexactvec),
),
'modf':
Ufunc(1, 2, None,
docstrings.get('numpy.core.umath.modf'),
None,
TD(inexactvec),
),
'ldexp' :
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.ldexp'),
None,
[
TypeDescription('f', None, 'fi', 'f'),
TypeDescription('f', FuncNameSuffix('long'), 'fl', 'f'),
TypeDescription('d', None, 'di', 'd'),
TypeDescription('d', FuncNameSuffix('long'), 'dl', 'd'),
],
),
'frexp' :
Ufunc(1, 2, None,
docstrings.get('numpy.core.umath.frexp'),
None,
[
TypeDescription('f', None, 'f', 'fi'),
TypeDescription('d', None, 'd', 'di'),
],
),
# 'gcd' :
# 'lcm' :
# 'matmul' :
}

def indent(st, spaces):
Expand Down
Loading

0 comments on commit 87b59b3

Please sign in to comment.