Hi Ford,
The kornia library has a full module dedicated to this kind of stuff. You can find nice implementations of differentiable operations like spatial gradients, sobel filters, etc that might suit your needs:

  
      
      kornia.readthedocs.io
  
  
    

kornia.filters — Kornia  documentation 191



  
  
    
    
  
  


Cheers,
Adrian