On Wed, Jul 08, 2015, Samuel Leeman-Munk wrote:
> Is there a speed penalty for elementwise? I imagine blas is optimized for
> non-elementwise matrix multiplication (more like dot than *)
Well, dot and * are different operations, and you cannot really use one
instead of the other, so I'm not sure what do you mean by "penalty".
The dot product of an (m, n) matrix by an (n, p) matrix is O(m*n*p) in
theory, and the elemwise product of two (m, n) matrices is O(m*n), so
even if blas optimizes dot, the elemwise product should still be faster.
Also, elemwise product is easily parallelized on GPU and even modern
CPUs (provided the memory layout is contiguous), so it is usually not
a bottleneck.
>
> On Wednesday, April 17, 2013 at 6:55:17 PM UTC-4, Dmitry Lagun wrote:
> >
> > Thanks!
> >
> > On Wednesday, April 17, 2013 6:55:42 PM UTC-4, Pascal Lamblin wrote:
> >>
> >> Hi Dmitry,
> >>
> >> On Wed, Apr 17, 2013, Dmitry Lagun wrote:
> >> > I could not quickly find in the documentation - is there some analog of
> >> > element wise matrix multiplication implemented in Theano?
> >>
> >> You can simply use '*':
> >> a, b = theano.tensor.matrices('a', 'b')
> >> f = theano.function([a, b], a * b)
> >> f([[0, 1], [2, 3]], [[3, 1], [0, 2]])
> >>
> >> array([[ 0., 1.],
> >> [ 0., 6.]])
> >>
> >>
> >> --
> >> Pascal
> >>
> >
>
--
Pascal