Iainmon / ChAI

A Chapel library for Machine Learning that supports distributed inference, automatic differentiation, and CUDA/HIP utilization.
https://iainmon.github.io/ChAI
4 stars 5 forks source link

[Feature request] Option for `padding` in `Conv2d` #7

Open ShreyasKhandekar opened 2 months ago

ShreyasKhandekar commented 2 months ago

Currently Conv2d in ChAI does not support a parameter for padding. Although this can potentially be done without Conv2d having to support it as a parameter, it would be nice if we could support it to add it to all 4 sides of the input automatically within the layer.

See pytorch for reference: https://pytorch.org/docs/stable/generated/torch.nn.Conv2d.html#torch.nn.Conv2d

Iainmon commented 1 month ago

I thought about adding this, but the gradient kernel for the convolution operation with arbitrary kernel size, input channels, output channels, stride, and padding, is extremely difficult to implement. I think the forward kernel could be done trivially though. Let me know if this is a blocker for anything and I will write it.

Iainmon commented 1 month ago

Added the most basic level of support for this in https://github.com/Iainmon/ChAI/pull/14 . I will work on adding more