Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Newbie question about loop fusion and broadcasting

$
0
0

Dear JuliaLang,

I’m excited to get started with Julia as a long-time Python user, tired of typing np.array. One thing that is really exciting to me is the ability to avoid writing my own ufuncs, especially avoiding the slow but easy to write frompyfunc ones.

One thing that is confusing me right now is the difference between, say, * and .*. Say I let x = randn(10), and I want to compute the outer product: x * x', aka x .* x'. These are of course the same, but from what I can tell they have different performance characteristics when combined with other broadcasted operations – the .* form can be fused with other broadcasted operations while * cannot.

However, to me, it seems like both of these are doing broadcasting, and that there is no room to interpret them differently from a mathematical point of view. So, is there an intuition for what underlying factor makes the difference for loop fusion? Is there just some loop fusion switch that gets turned on only when a . is present?

Thanks!

8 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795