This link from PWC-net might be helpful: https://github.com/deqings/PWC-Net/issues/1#issuecomment-404290729 24
As we know that the correlation is a flipped convolution in pure math but here it doesn’t function like that style. Conv2D receives an input feature and then convs it by a kernel defined by user. However, you see that cost volume involves two different feature maps. In this case, all research publication in optical flow needs to implement CUDA programming to do such “correlation”. Like: FlowNet,  FlowNet2, PWC-net. If pytorch is able to provide a official Correlation or CostVolume API, it would be great for both research and industry.
Here is the CUDA and python code from PWC-net.

  
      
      GitHub
  
  
    

NVlabs/PWC-Net 15

PWC-Net: CNNs for Optical Flow Using Pyramid, Warping, and Cost Volume, CVPR 2018 (Oral) - NVlabs/PWC-Net