I actually found out why I got so confused.
without dilation,
out = (in + 2*p - k)/s + 1
however, with dilation new kernel size k_d = d * (k-1) + 1,
Plugging this back into the above formula we have
out = (in + 2p - k_d)/s + 1
= (in + 2p - (d * (k-1) + 1))/s + 1
= (in + 2*p - d * (k-1) - 1)/s + 1
same as the one from doc.