I am using our internal compiler to convert an existing Pytorch model. However, some operations are not supported on our side, so we need to use some alternative implementation for the same operations.
For example, the original pytorch implementation of one layer is like this:
x = x / x.norm(dim=-1, keepdim=True)
I changed it to
x = x / torch.sqrt(torch.sum(x**2, dim=-1, keepdim=True))
the original implementation of the finally layer (it is a segmentation network like unet) is like this:
x = F.interpolation(x, size=(256, 256), mode='bilinear')
and I changed it into multiple less aggressive interpolation and stacked them like this
x = F.interpolation(x, size=(64, 64), mode='bilinear')
x = F.interpolation(x, size=(128, 128), mode='bilinear')
x = F.interpolation(x, size=(256, 256), mode='bilinear')
It kind of worked because I can perform training and got some decent result. However, the new result seems to be slightly worse than earlier, and I am not sure if it is due to the above modifications.
Could someone please provide some comments whether the above modifications are correct? Thanks.