Skip to content
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

In Place Convolution? #378

Closed
Luapulu opened this issue Sep 22, 2020 · 2 comments · Fixed by #545
Closed

In Place Convolution? #378

Luapulu opened this issue Sep 22, 2020 · 2 comments · Fixed by #545

Comments

@Luapulu
Copy link

Luapulu commented Sep 22, 2020

Could we get an in place conv! function?

Looking at the code, it seems like you'd only need to add a function that compares which of the inputs is larger and calls _conv! directly.

@galenlynch
Copy link
Member

Yeah, I've actually been working on a PR that improves conv quite a bit by allowing direct convolution, and adding multithreading to most of the algorithms. It would be simple to add in place convolution to that. I've been pretty busy with my research and sort of stalled out on the PR, but I'll try to pick it up soon.

@rafaqz
Copy link

rafaqz commented Nov 11, 2020

Just came here to add this too.

It would also be good to have a no-allocation conv! where you can pre-allocate everything it needs and pass it in. I have to run the same convolutions hundreds/thousands/millions of times and the allocations mean I pretty much can't use DSP.jl for that.

By the way, if you want to improve small matrix direct conv performance, I noticed that the direct windowing method in DynamicGrids.jl seems to be ~ 3x faster than DSP.jl for 3*3 kernels - although it's not written specifically for convolutions.

It uses @generated StaticArrays and blocking, and the compiler seems to inline and vectorise it pretty well (or something). It's ok for 5*5 but gets a lot slower from there.

Window iteration is here:
https://github.com/cesaraustralia/DynamicGrids.jl/blob/master/src/maprules.jl#L115-L142

@generated StaticArray buffer generation is here:
https://github.com/cesaraustralia/DynamicGrids.jl/blob/master/src/maprules.jl#L339-L390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants