[Numpy-discussion] speeding up operations on small vectors
Tue Oct 11 11:26:49 CDT 2011
2011/10/11 Skipper Seabold <firstname.lastname@example.org>
> On Tue, Oct 11, 2011 at 11:57 AM, Christoph Groth <email@example.com> wrote:
> > Pauli Virtanen <firstname.lastname@example.org> 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
> . 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 .
> I'd be very interested to hear if you achieve a great speed-up with
>  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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion