-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't spend your time on vectorizing your codes just to make things slower (CPU) #220
Comments
This title seems like clickbait. I think the term "vectorization" needs to be used with caution. As you know, its usage in the Python community, i.e. using (NumPy) arrays instead of for-loops, is not so common in other languages (e.g. Julia). The important thing to remember is that "premature optimization is the root of all evil". A "best" practice for getting speed is to paste the target code into the Discourse with the title "Why is Julia slower than Python?" 😝 |
I'm trying to collect some ideas for a series juliaimages blog posts or tutorials to explain some of the core ideas to write "native" julia codes in a way that JuliaImages developers do. I open this as I believe this is something very important for users who are doing image processing in dynamic languages like Matlab/Python. This actually isn't about premature optimization; in Matlab/Python a lot of people faithfully believe the power of vectorization when optimizing the codes. Without explaining why it doesn't work in Julia, they would otherwise try to invent all the wheels like https://julialang.org/blog/2017/01/moredots/ is a good explanation on this topic, but I'm thinking of a more concrete image processing example in real-world so that it attracts our users' attention. |
I agree that having a couple of short image-processing examples, coupled with a reference to a more detailed yet more general discussion elsewhere, would make a lot of sense. |
People in Python and Matlab communities enjoy "vectorizing my image processing pipeline and getting a big performance boost" story. The only reason for that is because for-loop is slow in Matlab/Python, and vectorizing the pipeline is indeed a tradeoff between "calling fast C/Fortran backend" and "overhead in intermediate memory allocation".
In Julia, unless you're writing GPU codes, use simple for-loop should be easier to write, and usually get you 2x-3x performance boost than vectorized codes.
And a lot of functions or helper utils (e.g.,
im2col/col2im
#219) becomes useless in Julia because we don't need to twist our mind to vectorize the codes to get high performance.Reference: https://julialang.org/blog/2017/01/moredots/
The text was updated successfully, but these errors were encountered: