I’ve ported weights from several Google AI Tensorflow models (EfficientNet, MixNet, MnasNet, etc). These weights require this type of padding so I created a factory of sorts that allows selecting between a PyTorch symmetric padding that comes close to ‘SAME’ and actually matching the TF ‘SAME’ with asymmetric padding when needed for compatibility.
Note that the Tensorflow compatible padding has a runtime penalty since I implemented it in a way that is dynamic based on input size (as opposed to requiring the input size passed in at model creation time). This pentaly is not worth paying if you don’t need compatibility with TF weights.
Current version of this lives here with the mixed kernel convolutions from MixNet: https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/conv2d_helpers.py 401
My impl does work well with several TF models so I assume it’s reasonably close to correct. May be some issues/scenarios I haven’t tested well wrt dilations, etc. Any feedback welcome. There are lots of discussion on this out there in various forums or issue trackers. Mistakes in many of those too