解决策略
将pad的算子进行变化
n, c, h, w = im.shape
im_padded = F.pad(im, pad=[1, 1, 1, 1], mode='constant', value=0)
改为
n, c, h, w = im.shape
im_padded = torch.cat((torch.zeros((n, c, h, 1)).to(im.device), im), dim=3)
im_padded = torch.cat((im_padded, torch.zeros((n, c, h, 1)).to(im.device)), dim=3)
im_padded = torch.cat((im_padded, torch.zeros((n, c, 1, w + 2)).to(im.device)), dim=2)
im_padded = torch.cat((torch.zeros((n, c, 1, w + 2)).to(im.device), im_padded), dim=2)
参考资料
github:Dynamic Input. IShuffleLayer applied to shape tensor must have 0 or 1 reshape dimensions