kernels.py
def my_cdist(x1, x2):
            """
            Computes a matrix of the norm of the difference.
            """
            x1 = torch.t(x1)
            x2 = torch.t(x2)
            x1_norm = x1.abs().sum(dim=-1, keepdim=True)
            x2_norm = x2.abs().sum(dim=-1, keepdim=True)
            res = torch.addmm(x2_norm.transpose(-2, -1), x1, x2.transpose(-2, -1), alpha=-2).add_(x1_norm)
            res = res.clamp_min_(1e-30).sqrt_()
            return res

            Computes a matrix of the norm of the difference.
            
Computes a matrix of the norm of the difference.
Computes a matrix of the norm of the difference .
def my_cdist(x1, x2):
            x1 = torch.t(x1)
            x2 = torch.t(x2)
            x1_norm = x1.abs().sum(dim=-1, keepdim=True)
            x2_norm = x2.abs().sum(dim=-1, keepdim=True)
            res = torch.addmm(x2_norm.transpose(-2, -1), x1, x2.transpose(-2, -1), alpha=-2).add_(x1_norm)
            res = res.clamp_min_(1e-30).sqrt_()
            return res
def my_cdist ( x1 , x2 ) : x1 = torch . t ( x1 ) x2 = torch . t ( x2 ) x1_norm = x1 . abs ( ) . sum ( dim = - 1 , keepdim = True ) x2_norm = x2 . abs ( ) . sum ( dim = - 1 , keepdim = True ) res = torch . addmm ( x2_norm . transpose ( - 2 , - 1 ) , x1 , x2 . transpose ( - 2 , - 1 ) , alpha = - 2 ) . add_ ( x1_norm ) res = res . clamp_min_ ( 1e-30 ) . sqrt_ ( ) return res
Computes a matrix of the norm of the difference.
Computes a matrix of the norm of the difference .
"""
            Computes a matrix of the norm of the difference.
            """
x1
x2