Grid_sample one to many


I was wondering if is there a smart way to achieve what I call (for lack of better definition) one to many grid_sample.
What do I mean by that? instead of sampling N(many) (C x IH x IW) images using N(many) (OH x OW x 2) grids is it possible to have grid_sample to have a single image 1 (C x IH x IW) sampled with N (OH x OW x 2) grids? and why not also Many to One in wich many images are sampled at the same locations?

Is there a smart/fast way to achieve this (instead of looping over N calls to grid_sample)? It could be really interesting especially for sparse object detection in very big images or volumes.

The solution is simple:

reshape the grid as (1 X NOH x OW x2)
call grid_sample and reshape the output to (NxCxOHxOw)!

The downside is that you may have border issues due to the interpolation of coordinates in very different places…