zahirbilal:

I tried with nested looping and summation but that was inefficient.


You could try to use unfold to create the input patches and a matmul to implement the convolution as given in the Unfold docs 2.
Note that this would most likely still be slower than the native implementations.