PyTorch RoI pooling implementation deviation

Your code looks fine.
Apparently the kernels of F.adaptive_max_pool2d overlap for odd input sizes:

a = torch.zeros(1, 1, 5, 5)
a[0, 0, 2, 4] = 1.0
F.adaptive_max_pool2d(a, (2, 2))
> tensor([[[[ 0.,  1.],
          [ 0.,  1.]]]])

I’m not sure this is wanted behavior.