[Numpy-discussion] speeding up operations on small vectors

Olivier Delalleau shish@keba...
Tue Oct 11 11:26:49 CDT 2011

2011/10/11 Skipper Seabold <jsseabold@gmail.com>

> 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
Another idea would be to use Theano (
http://deeplearning.net/software/theano/). It's a bit overkill though and
you would need to express most of your algorithm in a symbolic way to be
able to take advantage of it. You would then be able to write your own C
code to do the array operations that are too slow when relying on numpy.
If you are interested in pursuing this direction though, let me know and I
can give you a few pointers.

-=- Olivier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20111011/cd6cce0a/attachment.html 

More information about the NumPy-Discussion mailing list