@zahra Not sure how you have customised the correlate2d and convolve2d, but this is most likely due to copying back and forth, the tensors between device and  host which is a slow process. Difficult to say more without looking at the code.