I imagine you could use the output rule of SpatialGridSamplerBilinear and differentiate that to find what the gradient should be. It is a little complicated though and I don’t know where to find more information on this (https://arxiv.org/pdf/1506.02025.pdf 2 is the paper on Spatial Transformer Networks but I don’t think it describes a grid sampler like this).
I implemented the cuda code by translating https://github.com/pytorch/pytorch/blob/master/torch/lib/THNN/generic/SpatialGridSamplerBilinear.c 4 directly to cuda. Feel free to toss up a pr if you think shared memory will help speed up the computation! (I’m not entirely sure what you mean so it would be great if you could elaborate  )
In general my advice for implementing updateGradInput for a new operation is to write down the expression for updateOutput and differentiate it by hand and then put that into code.