PyTorch backprops through nn.unfold/fold.



 asrinivas:

More specifically, for the speedup part, if anyone has benchmarked implementing a regular conv2d with unfold + matmul + fold and compared the two on a GPU, that would be great to know!


The native aka THNN convolutions are implemented using im2col, so you can just disable CuDNN to benchmark whatever network you want. It uses a lot of memory and it won’t be fast. Part of that is the inefficiency in memory accesses when the im2col result is materialized in GPU memory (as opposed to living only in shared memory).
Best regards
Thomas