Time and Space Complexity of Conv2d?

hi everyone, I have been reading posts here for awhile, but this is my first topic in this friendly community ^^

I’m interested in pytorch’s convolution layer:
mainly in estimating the number of floating point operations, time and additional space complexity…

-so far my floating point operations calculation was derived strictly from the mathematical equation, and I got the following expression: FP_Ops=HWC_out*(2C_inK^2 + 1).
-I didn’t find the actual conv2d implementation code under the “nn/functional.py” file,
I was hoping for your help in finding the time and additional space complexity (or a direction to the source code is possible).

Thanks in advance and have a great week!

I don’t know the exact implementation of the convolution operation, but I doubt it’s the “vanilla” convolution.
Pete Warden explains in this blog post how im2col works for convolutions, but since this post is from 2015, I am sure there are more efficient operations used today. :wink:

Some core devs will surely have more insight.

1 Like

thanks!
Can a core devs validate and maybe share a source code example?
Would I be able to open and make my own improvements to this “im2col GEMM” code, thus making my very own conv2D kernel based on the existing one?? :slight_smile: