output of convolution for stride=1 is input - kernel_size + 1. This is a valid convolution, not same convolution.
If you want output width to be same as input width, you need to add additional implcit padding to input, given by Conv1d’s padding argument: https://pytorch.org/docs/stable/nn.html#conv1d 18