Repository: pytorch
Issue: Different implementations of upsampleBilinear between pytorch and caffe2
Labels: caffe2

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->
First, this is not actually a bug, but when one uses pytorch to train a model and then convert the model to onnx which later will be used to do inference by Caffe2, then different result just happened!
## To Reproduce
Let's take a look at what bilinear upsample implementation in aten/THNN/generic/SpatialUpsamplingBilinear.cc and caffe2/operators/upsamle_op.cc.   
1. In pytorch, upsampleBilinear operator is done through 2 functions, i.e. linear_upsampling_compute_scale and linear_upsampling_compute_source_index. Specifically,  by invoking linear_upsampling_compute_scale, pytorch first calculates something simliar to scale, then it will call linear_upsampling_compute_source_index to calculate source_index from dst_index and scale previously computed. 
2. In Caffe2, things become a little different. Specifically,  in upsample_op.cc, const float rheight = (input_height > 1)
      ? (float)(output_height - 1) / (input_height - 1)
      : 0.f; this variable has the similar meaning to scale, then on line 125, by rheight * h2 , it calculates src_index.;
<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->
A simple example that can reproduce the difference is as follows:
`import torch
import torch.nn as nn
import torch.nn.functional as F
import onnx
import caffe2.python.onnx.backend as bk

h = 3
w = 3


class TestModel(nn.Module):
    def __init__(self):
        super(TestModel, self).__init__()

    def forward(self, x):
        x = F.interpolate(x, (h + 1, w + 1), mode='bilinear')
        return x


torch_model = TestModel()
dummy_input = torch.randn(1, 3, h, w)
print(dummy_input[0, 0])
torch_model.eval()
torch.onnx.export(torch_model, dummy_input, 'tmp_model.onnx', export_params=True, verbose=True)
with torch.no_grad():
    torch_out = torch_model(dummy_input).numpy()
print('Now the result infered by pytorch is :')
print('*' * 50)
print('pytorch result is ')
print(torch_out[0, 0])
print('-' * 50)
onnx_model = onnx.load('tmp_model.onnx')
onnx.checker.check_model(onnx_model)
preprared_backend = bk.prepare(onnx_model)
c2_out = preprared_backend.run(dummy_input.numpy())[0]
print('caffe2 result is ')
print(c2_out[0, 0])
`
## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## Environment
Pytorch 1.0
Centos7
Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

You can get the script and run it with:
```
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```

 - PyTorch Version (e.g., 1.0):
  PyTorch1.0
 - OS (e.g., Linux): Centos7
 - How you installed PyTorch (`conda`, `pip`, source): source 
 - Build command you used (if compiling from source): python setup.py install
 - Python version: Python3.6.4
 - CUDA/cuDNN version: CUDA9.0, cuDNN 7.3.1
 - GPU models and configuration: V100
 - Any other relevant information:

## Additional context

<!-- Add any other context about the problem here. -->