Your approach works, but you should enter a stride, otherwise you get a very large output!
# load in a big image
big_image = torch.randn(1, 3, 2048, 2048)

# unfold the image into (b_size, 3 x 256 x 256, num_of_folds)
small_flat_imgs = f.unfold(big_image, kernel_size=256, stride=64)
print(small_flat_imgs.shape)
>> torch.Size([1, 196608, 841])


# test if upper-left corner are identical
print(torch.equal(small_flat_imgs[:,:,0].view(-1, 3, 256, 256), big_image[:, :, :256, :256]))
>> True

small_imgs = small_flat_imgs.view(-1, 3, 256, 256)
print(small_imgs.shape)
>> torch.Size([841, 3, 256, 256])

For F.fold I’m to stupid and would be happy about a answer by ptrblck!