Convolution operation can be converted to matrix multiplication using [1] 11 [2] 10    and then you can use torch.matmul()   . My question is i have to replace the addition and multiplication with my own functions mymult(num1,num2) and myadd(num1,num2). Currently i am using loops to replace torch.matmul() and multiply and add element wise which is really really slow. I would like to somehow make it vectorize or use broadcasting i am not sure how to do that. In short i would like to make it faster.