You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to speed up MKDAChi2(), I noticed COO matrix sum takes a lot of time.
Additional details
Examples here and here. It seems to me that the implementation of sum in sparse only uses np.add.reduce without any optimization (I opened an issue there waiting for response).
Next steps
I tried some simple optimization like below using numba, which makes it much faster. (There are many better ways to implement this. Also maybe there are ways to avoid calculating the sum.)
fromnumbaimportnjit@njitdef_coo_sum_axis_0(shape, coords, data):
res=np.zeros(shape)
foriinrange(len(data)):
x, y, z=coords[1:, i]
res[x, y, z] +=data[i]
returnres# _coo_sum_axis_0(ma_maps.shape[1:], ma_maps.coords, ma_maps.data)
The text was updated successfully, but these errors were encountered:
Summary
When trying to speed up
MKDAChi2()
, I noticed COO matrix sum takes a lot of time.Additional details
Examples here and here. It seems to me that the implementation of
sum
insparse
only usesnp.add.reduce
without any optimization (I opened an issue there waiting for response).Next steps
I tried some simple optimization like below using numba, which makes it much faster. (There are many better ways to implement this. Also maybe there are ways to avoid calculating the sum.)
The text was updated successfully, but these errors were encountered: