dfdx icon indicating copy to clipboard operation
dfdx copied to clipboard

`Conv2d` with non square kernel/stride/padding/dilation

Open infalmo opened this issue 2 years ago • 2 comments

How would I create a kernel with a non-square/rectangular shape? Something like:

Conv2D<_, _, (5, 3)> 

infalmo avatar Jan 24 '23 09:01 infalmo

Currently unsupported, but definitely interested in supporting this (plus strides/padding with different values for both dimensions). The underlying internals updates will be fairly straightforward (though maybe numerous).

The main challenge here will be figuring out to support 1d kernel size and 2d kernel ergonomically. This is another place I wish you could use tuples of usizes in const setting, but we may need to depend on trait Shape or something similar here:

Conv2D<(Const<3>, ) , 2, 1>
Conv2D<(Const<3>, Const<2>), 

The downside of moving to shapes/dims is then I don't think we can support Conv2D<3, 2, 1> anymore 😩

coreylowman avatar Jan 24 '23 14:01 coreylowman

One thing we could do is add this to the tensor op level (so someone could then easily add their own nn Conv2D wrapped around this), but not add it to the dfdx nn Conv2D.

coreylowman avatar May 09 '23 12:05 coreylowman