Implementing Custom nn.functional.conv2d


(Kyeong Jun Lee) #1

How I want to implement Custom nn.functional.conv2d.
What is the fastest way to calculate convolution result & gradient in PyTorch?

`class MyConv2d(torch.autograd.Function):
@static_method
def forward(ctx, *args):
result = “How To Calculate Convolution”
result = result * (my custom function)
return result

@static_method
def backward(ctx, grad_output):
result = “How To Calculate Gradient?”
result = result * (my custom function)
return result

`