-
Notifications
You must be signed in to change notification settings - Fork 285
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
Optimize aamp for p==2
(and maybe p==1
)
#729
Comments
@seanlaw |
Sure! Might as well take care of p=1 as well if there is something there. Will all non-normalized functions use this? |
I think it will be used in We also have the argument |
Where in What about |
UPDATEPlease allow me first to provide a little info regarding the impact of the two proposed function (see the first comment) on the computing time: In what follows:
Note that In
Now, by using
Tables of Performances
Note that The improvement in computing time for gpu_aampIn PART-I:
Here, we can investigate and see if we can improve the computing time. Note that we use PART-II:
I think this is similar to the updating process in maampI can see the following cases in different parts of the codes
I feel the three items above should be fine. But, still, we should investigate.
we may try to optimize it (this seems to be similar to the updating process). For now, I just investigated |
@seanlaw |
Great! I don't love
But
Hmmm, now that I think about it. Let's put this one on pause for now until we've wrapped up all of the other more important stuff like fixing precision issues. I'm not sure that this is an immediate "value add" for users while many of the other stability related things are a definite value-add! |
Yeah...I know! I tried (a little bit) to find a better name but couldn't.
Right!
Sure :) The thing that triggered my mind was that the computing time for I will leave it here, and will try to resume recording the computing time for |
@seanlaw I realized that there is a huge difference in the computing time between
And, the input:
I am not saying this is the only place that code can be optimized, but it seems that this is a very important thing! Maybe, we do something similar to
Btw, I posted a question on numba discourse: |
@NimaSarajpoor That is interesting! It seems that raising a |
If p is an integer, the compiler can unroll the loop inside pow(x, 2) to x*x. |
Very insightful! Thanks for sharing @JaKasb! |
@NimaSarajpoor I think we may be able to use a built-in Python function:
|
Currently,
aamp
accepts argumentp
(with default2.0
) to calculate p-norm distance. According to a code written by scipy community, it is better to usenp.square(..)
whenp is 2
.Let's compare
The
OPTIMIZED
version is by adding the two following functions instumpy/core.py
, and use them instumpy/aamp.py
We may want to investigate
p==1
case as well and do the same. I mean...we may do:np.sum(np.abs(...))
)p==1
andp==2
are the most common cases and it would be good to reduce computing time for these two cases.The text was updated successfully, but these errors were encountered: