Conv2D source code

I was trying to look at the implementation of the 2D convolution on PyTorch. I found Conv2D class, which is using F.conv2, but I can’t get to the source code for the actual implementation, except for these 2 lines:

@overload
def conv2d(input: Tensor, weight: Tensor, bias: Optional[Tensor]=None, stride: Union[_int, _size]=1, padding: Union[_int, _size]=0, dilation: Union[_int, _size]=1, groups: _int=1) -> Tensor: ...
@overload
def conv2d(input: Tensor, weight: Tensor, bias: Optional[Tensor]=None, stride: Union[_int, _size]=1, padding: str="valid", dilation: Union[_int, _size]=1, groups: _int=1) -> Tensor: ...

Would appreciate if someone can direct me to the right place. Thanks!

Of course because PyTorch is open-source you can see it, but when using it within a python code you actually run a pre-compiled C++ code so it isn’t available.
The actual implementation can be found on GitHub

This is true for a lot of “basic” things in PyTorch.

1 Like