Thanks for the unfold trick, I tested this and it gave a speedup of 39x  I was thinking earlier about some way of expanding B so it would match the topology of the corr[] result, but couldn’t find the method.
I guess it does require a bunch of passes over the data, because of the multiple chained unfolds, so perhaps it could be made faster if there was indeed a CUDA primitive that did it all in one pass, but I’ll be able to search for that later when this become a bottleneck again 
BTW, in a special case, A and B are the same array, and in that case it looks eerily similar to some kind of 2D auto-correlation (of a limited offset size), something you’d expect there to be a primitive for somewhere maybe.