Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork11.9k
BUG: Fix norm type promotion#10667
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
eric-wieser commentedFeb 26, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
eric-wieser commentedFeb 26, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Edit: I'm wrong. Thanks to#10374, I think that there's a deeper problem here with numpy type promotion, and how |
kmaehashi commentedFeb 26, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Ah, I see. x=np.ndarray(1,dtype=np.float32)x**=1.0/2.0x.dtype# => float32x=np.float32(1)x**=1.0/2.0x.dtype# => float64
I think the code in this PR is generic (i.e., works with both scalar and array). importnumpyasnpprint('scalar',np.linalg.norm(np.ones((2,),dtype=np.float32),3,0,False).dtype)print('array',np.linalg.norm(np.ones((2,2),dtype=np.float32),3,0,False).dtype) Output from NumPy 1.14.1: Output from NumPy 1.14.1 + this PR: |
eric-wieser commentedMar 18, 2018
Fix looks good, but this needs a test. |
I tested
np.linalg.normwith the following code, but it seems the type is not preserved correctly.Without this fix (NumPy 1.14.1):
With NumPy 1.14.1 + this fix, nothing should be printed.
Related to#10368 andcupy/cupy#875 (comment)