Could anyone explain how this CUDA version of convolution works ?

Hi,

It does the backward pass wrt the input. So the reverse of the forward.

Given the names, it performs unpooling (I guess the forward has some pooling builtin.

Then im2col that creates the Teoplitz matrix of the input (https://en.wikipedia.org/wiki/Toeplitz_matrix).

Then a matrix matrix multiplication between this and the weights.

This will give the result. (the backward of a conv is a conv. Here implenented using a Toeplitz matrix).

Wait, how does *im2col* create a toeplitz matrix of the input ?

You can see it here: https://stackoverflow.com/questions/16798888/2-d-convolution-as-a-matrix-matrix-multiplication

But it is moving data around in a new Tensor.

What did you exactly mean by this sentence above ?

Could you pinpoint the exact line of code ?

Besides, what is the purpose of following lines of code ?

`int uppool_Ho = (Hi + Kh - 1);`

`int uppool_Wo = (Wi + Kw - 1);`

And how do I interpret int transpose_uppool_blocks = (N * Co * Ho * Wo + transpose_uppool_threads -1) / transpose_uppool_threads; ?

What did you exactly mean by this sentence above ?

It computes the gradient of the loss wrt of the input of the convolution using the gradient of the loss wrt the output.

Could you pinpoint the exact line of code ?

Itâ€™s not just one line, it is the whole function.

Besides, what is the purpose of following lines of code ?

Not sure, it computes the output sizes of the unpooling right?

What did you exactly mean by â€śunpoolingâ€ť ?

What do we have size(1), size(2) and size(3) ?

```
int Co = grad_y.size(1);
int Ho = grad_y.size(2);
int Wo = grad_y.size(3);
```

Iâ€™m not sure what it means exactly in this context, but in general itâ€™s about the reverse of a pooling op. For maxpooling for example, we have this: https://pytorch.org/docs/stable/nn.html#torch.nn.MaxUnpool1d