Adding a new parameter to conv2d

Hi,

I would like to add a parameter to the function SpatialConvolutionMM_updateOutput(…, int newParam) from “aten/src/THCUNN/generic/SpatialConvolutionMM.cu”.

Things I changed so far:

  • I added the new parameter to the thnn_conv2d():in “aten/src/ATen/nn.yaml”

  • also added the new parameter to conv2d: in " /ATen/native/native_functions.yaml"

Compile errors I obtain:
aten/src/ATen/TypeDefault.h:782: “candidate expects 9 arguments, 10 provided”
aten/src/ATen/TypeDefault.h:783: “candidate expects 6 arguments, 7 provided”

1 Like

Hi,

I guess you will need to change the implementation in THNN as well. Also keep in mind that this might break some python part of pytorch that expects the convolution to take less arguments.
If you don’t need all the utilities from THCUNN, it might be simpler to create a cpp extension with your modified function.

1 Like

Unfortunately updating SpatialConvolutionMM.c in THNN does not resolve the error.

Do you know how to change the declaration of thnn_conv2d_forward_out() and thnn_conv2d_forward() in the autogenerated Declarations.yaml file “build/aten/src/ATen/Declarations.yaml”?

Changing them in derivatives.yaml “/tools/autograd/derivatives.yaml” does not yield a result.

1 Like

Hi,

As stated above this is very dangerous to do and will require quite significant changes to the whole backend as many functions assume the current interface for conv and will need to be modified.
I would advice doing a cpp extension containing your modified convolution.

For any reader who stumbles upon this - here you can find out how to solve it: https://github.com/pytorch/pytorch/issues/12320.