Dilated convolution does not preserve the spatial resolution

Hi, I use dilated convolution by setting dilation=1 when defining the convolution layers. The input images have spatial resolution 128 by 128, but the output of the network has a smaller resolution (124 by 124). In my understanding, the dilated convolution should keep the resolution. Where goes wrong? Thanks!

I got the answer. There is a formula which describes the output shape:

Lout=floor((Lin+2∗padding−dilation∗(kernel_size−1)−1)/stride+1)

Therefore, in order to keep the dimension, we need to add paddings which equals the dilation size.