[Numpy-discussion] speeding up operations on small vectors
Skipper Seabold
jsseabold@gmail....
Tue Oct 11 11:11:01 CDT 2011
On Tue, Oct 11, 2011 at 11:57 AM, Christoph Groth <cwg@falma.de> wrote:
> Pauli Virtanen <pav@iki.fi> writes:
>
>>> Thank you for your suggestion. It doesn't help me however, because
>>> the algorithm I'm _really_ trying to speed up cannot be vectorized
>>> with numpy in the way you vectorized my toy example.
>>>
>>> Any other ideas?
>>
>> Reformulate the problem so that it can be vectorized. Without knowing
>> more about the actual algorithm you are trying to implement, it's not
>> easy to give more detailed help.
>
> My question was about ways to achieve a speedup without modifying the
> algorithm. I was hoping that there is some numpy-like library for
> python which for small arrays achieves a performance at least on par
> with the implementation using tuples. This should be possible
> technically.
So it's the dot function being called repeatedly on smallish arrays
that's the bottleneck? I've run into this as well. See this thread
[1]. You might gain some speed if you drop it down into Cython, some
examples in that thread. If you're still up against it, you can try
the C code that Fernando posted for fast matrix multiplication (I
haven't yet), or you might be able to do well to use tokyo from Cython
since Wes' has fixed it up [2].
I'd be very interested to hear if you achieve a great speed-up with
cython+tokyo.
Cheers,
Skipper
[1] http://mail.scipy.org/pipermail/scipy-user/2010-December/thread.html#27791
[2] https://github.com/wesm/tokyo
More information about the NumPy-Discussion
mailing list