I find it is apparently different between the two APIs( tf.image.crop_and_resize vs torchvision.ops.roi_align). I provide the example here:
import numpy as np
b = np.arange(100*100).reshape(1, 100, 100, 1)
boxes = [12, 30, 42, 53]
x1 = boxes[0] / (100-1)
x2 = boxes[2] / (100-1)
y1 = boxes[1] / (100-1)
y2 = boxes[3] / (100-1)

import tensorflow as tf
res = sess.run(tf.image.crop_and_resize(b, [[y1, x1, y2, x2]], [0], [7, 7])).transpose([0, 3, 1, 2])
# transpose is for comparison with the result of pytorch
print("tensorflow:", res)

# pytorch 1.7
from torchvision.ops import roi_pool, roi_align
res1 = roi_align(torch.from_numpy(b.transpose([0, 3,1,2]).astype(np.float32)), torch.from_numpy(np.asarray([[0, boxes[0], boxes[1], boxes[2], boxes[3]]]).astype(np.float32)), output_size=(7, 7))
print(res1)

The two results are:
tf:
[[[[3012.     3017.     3022.     3027.     3032.     3037.
3042.    ]
[3395.3333 3400.3333 3405.3333 3410.3333 3415.3333 3420.3333
3425.3333]
[3778.6667 3783.6667 3788.6667 3793.6667 3798.6667 3803.6667
3808.6667]
[4162.     4167.     4172.     4177.     4182.     4187.
4192.    ]
[4545.333  4550.333  4555.333  4560.333  4565.333  4570.333
4575.333 ]
[4928.6665 4933.6665 4938.6665 4943.6665 4948.6665 4953.6665
4958.6665]
[5312.     5317.     5322.     5327.     5332.     5337.
5342.    ]]]]

pytorch:
tensor([[[[3178.4287, 3182.7141, 3187.0000, 3191.2856, 3195.5713, 3199.8569,
       3204.1428],
      [3507.0000, 3511.2856, 3515.5710, 3519.8569, 3524.1426, 3528.4285,
       3532.7141],
      [3835.5715, 3839.8579, 3844.1426, 3848.4285, 3852.7144, 3857.0000,
       3861.2859],
      [4164.1426, 4168.4287, 4172.7139, 4177.0000, 4181.2856, 4185.5713,
       4189.8574],
      [4492.7139, 4497.0000, 4501.2856, 4505.5713, 4509.8569, 4514.1426,
       4518.4287],
      [4821.2861, 4825.5718, 4829.8574, 4834.1431, 4838.4287, 4842.7144,
       4847.0000],
      [5149.8574, 5154.1421, 5158.4292, 5162.7144, 5167.0005, 5171.2856,
       5175.5713]]]])

The results are really different!
Does anyone know the reason? Thanks in advance.