-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Labels
Description
Describe the issue:
A 500 x 4096 by 4096 x 4096 float64 matrix multiplication takes ~90 seconds when the second matrix is the real part of a complex matrix. However, if I copy the real part first, it takes ~200 milliseconds.
Reproduce the code example:
Python 3.8.13 (default, Mar 28 2022, 06:16:26)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.7.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import numpy as np; import sys; print(np.__version__); print(sys.version)
1.21.2
3.8.13 (default, Mar 28 2022, 06:16:26)
[Clang 12.0.0 ]
In [2]: A = np.random.rand(500, 4096).astype(np.float64)
In [3]: B = np.random.rand(4096, 4096).astype(np.complex128)
In [4]: %time A @ B.real.copy()
CPU times: user 661 ms, sys: 32.5 ms, total: 693 ms
Wall time: 208 ms
Out[4]:
array([[1031.28559148, 1016.17905869, 1034.24549966, ..., 1056.87465704,
1026.28741105, 1038.26833557],
[1025.92445058, 1013.48585125, 1017.4986476 , ..., 1047.55891348,
1023.70195356, 1031.99613791],
[1065.46563622, 1031.90604975, 1050.00822611, ..., 1078.80268065,
1054.78029417, 1060.26089953],
...,
[1025.73960694, 1014.40748249, 1025.57724684, ..., 1046.70235119,
1024.04754168, 1029.73316398],
[1018.27542455, 1011.34196549, 1019.5848226 , ..., 1047.61990492,
1010.1769123 , 1008.49849528],
[1022.48335183, 1005.82987121, 1022.86583977, ..., 1042.67415337,
1018.51901983, 1024.17000994]])
In [5]: %time A @ B.real
CPU times: user 1min 27s, sys: 732 ms, total: 1min 28s
Wall time: 1min 29s
Out[5]:
array([[1031.28559148, 1016.17905869, 1034.24549966, ..., 1056.87465704,
1026.28741105, 1038.26833557],
[1025.92445058, 1013.48585125, 1017.4986476 , ..., 1047.55891348,
1023.70195356, 1031.99613791],
[1065.46563622, 1031.90604975, 1050.00822611, ..., 1078.80268065,
1054.78029417, 1060.26089953],
...,
[1025.73960694, 1014.40748249, 1025.57724684, ..., 1046.70235119,
1024.04754168, 1029.73316398],
[1018.27542455, 1011.34196549, 1019.5848226 , ..., 1047.61990492,
1010.1769123 , 1008.49849528],
[1022.48335183, 1005.82987121, 1022.86583977, ..., 1042.67415337,
1018.51901983, 1024.17000994]])Error message:
No response
Runtime information:
1.21.2
3.8.13 (default, Mar 28 2022, 06:16:26)
[Clang 12.0.0 ]
Context for the issue:
No response