Torch.nn.functional.grid_sample takes any value for mode

When I call:

torch.nn.functional.grid_sample(array_5d, indices, mode='anything')

mode can be anything. Why is that? Is there no mode to choose?

I would like to choose mode=‘trilinear’, is that available? In the docs I can see there is mode=‘bilinear’ as default.

Only bilinear is supported: https://pytorch.org/docs/master/nn.html?highlight=grid_sample#torch.nn.functional.grid_sample

But the code should really throw an error if you try to pass anything other than bilinear. I’ve opened an issue here: https://github.com/pytorch/pytorch/issues/8693 for this.

1 Like