|
|
深情的鞭炮 · Install .NET Runtime ...· 1 年前 · |
|
|
胆小的小蝌蚪 · Angular本地中转报错:[HPM] ...· 3 年前 · |
|
|
温文尔雅的镜子 · Docker之容器 - wenxuehai ...· 3 年前 · |
|
|
憨厚的黄豆 · java后台判断字符串是否为json格式_判 ...· 3 年前 · |
Activity
tupui commented
on
Dec 3, 2021
@treverhines can you have a look at this issue?
treverhines commented
on
Dec 4, 2021
@segasai Thanks for pointing this out. I am getting similar times on my machine: 13 seconds for
Rbf-based evaluation, and 35 seconds forRBFInterpolatorwith a single thread.The issue is that, in this case, the matrix multiplication done to evaluate the interpolant is significantly faster with
np.dotthan the implementation in_evaluate. The difference in times seems to get larger with higher dimensional data. If you lower the data vector dimensions down to something likenx=100, you should see thatRBFInterpolatoris either comparable or faster than theRbf-based evaluation. So this issue is just for interpolating high-dimensional data.If I replace this block:
scipy/scipy/interpolate/_rbfinterp_pythran.py Lines 220 to 222 15df208
with a call to
np.dot, then BLAS will be used to perform a matrix-vector multiplication for each evaluation point, and that brings the time down from 35 seconds to about 20 seconds on my machine. So not as fast as yourRbf-based evaluation; however, it is more memory efficient since theRbf-based evaluation requires holding a potentially large(neval, npts)matrix in memory.If I were to make that change,
_rbfinterp_pythran.pywould need to be compiled with BLAS, and I am not sure if that is a deal-breaker for scipy because of added build complications. FWIW, I have been pip installing pythran-openblas ( https://github.com/serge-sans-paille/pythran-openblas ) and compiling the pythran code with--config compiler.blas=pythran-openblas. Perhaps we can add pythran-openblas as a build dependency? @rgommerssegasai commented
on
Dec 5, 2021
Can you try reversing loop order from j,k to k,j if it makes a difference ?
treverhines commented
on
Dec 5, 2021
swapping the two for loops increased the time from 35 seconds to 154 seconds.
segasai commented
on
Dec 7, 2021
This change master...segasai:rbf_fix
allows me to reduce the time for the RBF evaluation from 27 seconds to 0.6 second. (basically I've moved np.dot out of the pythran file and only kept kernel/monomial calculations there)
Obviously there are potential memory implications here (we need to keep the matrix of coefficients in memory), but I'd say it's better to do chunking if we can get 50times better performance.
I was testing the performance of just this line in my code
treverhines commented
on
Dec 8, 2021
treverhinesContributorMore actionsAfter playing around with this a bit, I think I prefer your suggested approach of building the kernel and polynomial matrix in chunks and dotting each chunk with coeffs. Although, I would suggest keeping the chunking andnp.dotwithin_evaluatefor slightly better performance (build issues aside). Are you interested in making a PR? Otherwise, I can probably work on it later this month.segasai commented
on
Dec 8, 2021
segasaiContributor AuthorMore actionsI was planning to submit the PR based on what I have (i.e np.dot outside pythran). Personally I'd prefer not to delve into blas/lapack linking/building stuff/dependencies on pythran version, so if you think that np.dot has to be inside, I'll let you do it.closed this as completed in #15190
on Apr 30, 2022
added this to the 1.9.0 milestone
on Apr 30, 2022
added this to scipy.interpolate
on Jun 30, 2024
moved this to Done in scipy.interpolate
on Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment