So, are you implying that torch.cdist() function itself contains contiguous() call ?
I tried to replace torch.cdist() using fast_cdist() as shown below. However, I still have GPU out-of-memory error.
def fast_cdist(x1, x2):
    adjustment = x1.mean(-2, keepdim=True)
    x1 = x1 - adjustment
    x2 = x2 - adjustment  # x1 and x2 should be identical in all dims except -2 at this point

    # Compute squared distance matrix using quadratic expansion
    # But be clever and do it with a single matmul call
    x1_norm = x1.pow(2).sum(dim=-1, keepdim=True)
    x1_pad = torch.ones_like(x1_norm)
    x2_norm = x2.pow(2).sum(dim=-1, keepdim=True)
    x2_pad = torch.ones_like(x2_norm)
    x1_ = torch.cat([-2. * x1, x1_norm, x1_pad], dim=-1)
    x2_ = torch.cat([x2, x2_pad, x2_norm], dim=-1)
    res = x1_.matmul(x2_.transpose(-2, -1))

    # Zero out negative values
    res.clamp_min_(1e-30).sqrt_()
    return res


  
      github.com/huawei-noah/AdderNet
  
  
    
  
	  
  

  
    
      RuntimeError: _cdist_backward requires X2 to be contiguous 7
    

    
      
        opened 
        
          
        
        Mar 3, 2020
      
      

        
          closed 
        
          
        
        Mar 10, 2020
      
        

      
        
          
          ranery
        
      
    
  



  Hi, I am trying to train your addernet, but it returns me one runtime error, which I supposed attributes to .continuous()...