Random down sampling

Hello,

I have a tensor with size B,C,W,H and I generated random kernel with size 4x4 filled with zeros except one with one value. This kernel is multiplied with the the tensor and re-generated for each sliding process.

the result I have is the same tensor half filled with zeros. I want to downsample this tensor to half by removing only the zeros values and keeping it dimension. this can be done re-creating a new small tensor and copying each rows independently.

What it is not clear for me is the gradients, by doing this new tensor and copying am I keeping the flow of the gradients or loosing it ? or is there a better way to do it ?