Thanks to visit codestin.com
Credit goes to github.com

Skip to content

invalid special value handling of avx exp #13400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
juliantaylor opened this issue Apr 24, 2019 · 13 comments
Closed

invalid special value handling of avx exp #13400

juliantaylor opened this issue Apr 24, 2019 · 13 comments

Comments

@juliantaylor
Copy link
Contributor

Unfortunately I did not comment that on the original MR but there are errors in handling special values of the new float32 avx based exp and log functions.

executed on an axv2 machine, avx512 still needs to be tested
log:

d = np.ones(5, dtype=np.float32) * 1.121

# wrong result
d[...] = np.nan
print(np.log(d))
[89.1283 89.1283 89.1283 89.1283 89.1283]

# correct but raises divide by zero error, which glibc scalar function does not
d[...] = 0.
print(np.log(d))

# raises invalid value error
d[...] = -2. 
print(np.log(d))
d[...] = -np.inf
print(np.log(d))

exp

# raises invalid value instead of overflow
d[...] = 1e17
print(np.exp(d))

#raises invalid value
d[...] = np.nan
print(np.exp(d))
d[...] = np.inf
print(np.exp(d))
d[...] = -np.inf
print(np.exp(d))
@juliantaylor juliantaylor added this to the 1.17.0 release milestone Apr 24, 2019
@rgommers
Copy link
Member

This was gh-13134. @r-devulap could you have a look at this?

@r-devulap
Copy link
Member

yup, taking a look.

@r-devulap
Copy link
Member

Started a PR #13415 to fix this. Will fix the issue with log soon.

@r-devulap
Copy link
Member

PR #13415 is merged, perhaps this issue can be closed?

@seberg
Copy link
Member

seberg commented May 7, 2019

@r-devulap just before it gets lost, was this comment a possible problem with the current fix: #13415 (comment)

@r-devulap
Copy link
Member

yes, unfortunately I don't have access to a mac and I cannot reproduce that problem on my SKX with ubuntu and gcc/clang. But since that portion of test test_exp_values only cares about verifying the output of exp, I can may be ignore floating point errors by updating the test with np.errstate(all='ignore'). Would that be acceptable?

@mattip
Copy link
Member

mattip commented May 17, 2019

@tylerjereddy Is the occasional RuntimeWarning: invalid value encountered in exp on macOS still a valid concern or have they dissapeared?

@tylerjereddy
Copy link
Contributor

tylerjereddy commented May 17, 2019

@mattip Yes, I still get the following test failure output from the latest master branch commit (8a421d9) when running full test suite on my Mac laptop:

________________________ TestSpecialFloats.test_exp_values _________________________
[gw1] darwin -- Python 3.6.5 /Users/treddy/miniconda3/envs/numpy_dev_py36/bin/python

self = <numpy.core.tests.test_umath.TestSpecialFloats object at 0x11bccdac8>

    def test_exp_values(self):
        x = [np.nan,  np.nan, np.inf, 0.]
        y = [np.nan, -np.nan, np.inf, -np.inf]
        for dt in ['f', 'd', 'g']:
            xf = np.array(x, dtype=dt)
            yf = np.array(y, dtype=dt)
>           assert_equal(np.exp(yf), xf)
E           RuntimeWarning: invalid value encountered in exp

dt         = 'f'
self       = <numpy.core.tests.test_umath.TestSpecialFloats object at 0x11bccdac8>
x          = [nan, nan, inf, 0.0]
xf         = array([nan, nan, inf,  0.], dtype=float32)
y          = [nan, nan, inf, -inf]
yf         = array([ nan,  nan,  inf, -inf], dtype=float32)

numpy/core/tests/test_umath.py:659: RuntimeWarning
1 failed, 8641 passed, 63 skipped, 15 xfailed, 3 xpassed in 120.79 seconds

@tylerjereddy
Copy link
Contributor

I don't think it is occasional either--I haven't see any fluke passes lately. I could use pytest-repeat if you really need likelihood of failure, but seems to happen all the time for me on mac.

@charris
Copy link
Member

charris commented May 23, 2019

Hmm, this is unfortunate with 1.17 coming on soon.

@r-devulap
Copy link
Member

If I am not wrong, this particular issue was fixed. The test failure seems to be because of a bug in clang7.0 and a new issue was opened to address it (see #13586). Although, I am not fully sure how to address it..

@charris
Copy link
Member

charris commented Jun 6, 2019

@juliantaylor Just want to check if this can be closed.

@charris charris closed this as completed Jun 26, 2019
@charris
Copy link
Member

charris commented Jun 26, 2019

Closing as it seems to be fixed. I expect it will come up again if it persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants