# What's the status of image convolutions on CPU & GPU?

**URL:** <https://discourse.julialang.org/t/whats-the-status-of-image-convolutions-on-cpu-gpu/6093>\
**Category:** GPU\
**Created:** [September 26, 2017, 9:21pm UTC](https://discourse.julialang.org/t/whats-the-status-of-image-convolutions-on-cpu-gpu/6093 "2017-09-26T21:21:28Z")\
**Posts on this page:** 1\
**Showing post:** 39

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [October 7, 2017, 11:56am UTC](https://discourse.julialang.org/t/whats-the-status-of-image-convolutions-on-cpu-gpu/6093/39 "2017-10-07T11:56:47Z")

</div>

FastConv is nice if you want something that grows the array by the kernel size (like `conv2`, something I’ve never gotten around to implementing in ImageFiltering). Otherwise, though, `imfilter` is both faster and more general:

```julia
A = rand(1000,1000);
k = rand(3,3);
julia> @btime convn(A, k);
  15.451 ms (20 allocations: 7.66 MiB)

julia> @btime imfilter(A, (k,));
  12.473 ms (44 allocations: 15.32 MiB)

julia> B = view(A, 1:900, 1:900);

julia> @btime imfilter(B, (k,));
  10.139 ms (44 allocations: 12.42 MiB)

julia> @btime convn(B, (k,));
ERROR: MethodError: no method matching convn(::SubArray{Float64,2,Array{Float64,2},Tuple{UnitRange{Int64},UnitRange{Int64}},false}, ::Tuple{Array{Float64,2}})

```

---

_[View the full topic](https://discourse.julialang.org/t/whats-the-status-of-image-convolutions-on-cpu-gpu/6093)._
