abhi-glitchhg / np_conv

speed optimized convolutions in numpy
MIT License
4 stars 1 forks source link

Implement Conv2D #1

Closed abhi-glitchhg closed 1 year ago

abhi-glitchhg commented 1 year ago

Generally, the implementation of convolutions in numpy involves For loops. Generally, these implementations are a part of tutorials to understand the Convolution operation in Deep Learning/Image processing, but very rarely one talk about optimizing the convolution operation by leveraging the Powerful numpy APIs.

My current idea is to implement an optimized convolution operation using the as_strided function of the numpy library. Will try to implement it for different formats. eg channels first, channels last.

Also if possible, i will try to add dilations, and striding operations which are quite popular in Deep Learning frameworks like pytorch and Keras.

abhi-glitchhg commented 1 year ago

I am assuming here that we are working with c-contiguous numpy arrays. 😄

abhi-glitchhg commented 1 year ago

There is some bug with current code where if the dilation shape is of type (n,m) where n!=m, the code breaks and exits without any warning/error. I need to find the reason and how to handle this issue properly.

abhi-glitchhg commented 1 year ago

Fixed this issue in https://github.com/abhi-glitchhg/np_conv/commit/23bc643b2693ebda8b5e48779a55440188ea5d5b

abhi-glitchhg commented 1 year ago

Now that dilation and strides are working fine, I should try out to implement grouping of channels