Fold/unfold to get patches

I just do as you did in the mentioned post, so it’ll be:

x = image
kh, kw = 256, 256 # kernel size
dh, dw = 256, 256 # stride
patches = x.unfold(0, kc, dc).unfold(1, kh, dh)
unfold_shape = patches.size()
patches = patches.contiguous().view(patches.size(0), -1, kc, kh) #unsure
print(patches.shape)

Although I quite don’t understand the line with “unsure” tag.
And yes I know, but is there a way to do it without adding padding? like maybe having overlapping patches?