I wish to implement fourier domain based convolution, for which I wished to compare the complexity of my approach with the inbuilt conv2d layer’s complexity.
In the docs, the following formula is given for computing convolutional layer -
https://pytorch.org/docs/stable/nn.html#torch.nn.Conv2d 12
To get to the source code, I followed the ‘source’ button on the right of the formula which lead to the following page -
https://pytorch.org/docs/stable/_modules/torch/nn/modules/conv.html#Conv2d 10
This code used ‘functional.conv2d’, but the definition on the functional conv2d page did not have a link to the source code.
Some answers online suggested this is the entry point to the code for conv2d -

  
      github.com
  
  
    pytorch/pytorch/blob/c780610f2d8358297cb4e4460692d496e124d64d/aten/src/ATen/native/Convolution.cpp#L481 10

}




at::Tensor conv1d(
    const Tensor& input, const Tensor& weight, const Tensor& bias,
    IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, int64_t groups) {
  return at::convolution(input, weight, bias, stride, padding, dilation,
                         false, {0}, groups);
}


at::Tensor conv2d(
    const Tensor& input, const Tensor& weight, const Tensor& bias,
    IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, int64_t groups) {
  return at::convolution(input, weight, bias, stride, padding, dilation,
                         false, {{0, 0}}, groups);
}


at::Tensor conv3d(
    const Tensor& input, const Tensor& weight, const Tensor& bias,
    IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, int64_t groups) {
  return at::convolution(input, weight, bias, stride, padding, dilation,



  
  
    
    
  
  


But this link further points to mkldnn and cudnn implementations, which maybe implemented in the following files -

  
      github.com
  
  
    pytorch/pytorch/blob/master/aten/src/ATen/native/mkldnn/Conv.cpp 10
#include <ATen/ATen.h>
#include <ATen/NativeFunctions.h>
#include <ATen/Config.h>

#if !AT_MKLDNN_ENABLED()

namespace at { namespace native {

at::Tensor mkldnn_convolution(
    const at::Tensor& input, const at::Tensor& weight, const at::Tensor& bias,
    IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups) {
  AT_ERROR("mkldnn_convolution_forward: ATen not compiled with MKLDNN support");
}

at::Tensor mkldnn_convolution_backward_input(
    IntArrayRef input_size, const at::Tensor& grad_output, const at::Tensor& weight,
    IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool bias_defined) {
  AT_ERROR("mkldnn_convolution_backward_input: ATen not compiled with MKLDNN support");
}



  This file has been truncated. show original

  
  
    
    
  
  


and

  
      github.com
  
  
    pytorch/pytorch/blob/master/aten/src/ATen/native/cudnn/Conv.cpp 9
#include <limits>
#include <ATen/ATen.h>
#include <ATen/NativeFunctions.h>
#include <ATen/Config.h>
#include <ATen/cuda/CUDAConfig.h>
#include <ATen/cuda/Exceptions.h>
#include <ATen/native/ConvUtils.h>

#if !AT_CUDNN_ENABLED()

namespace at { namespace native {

// See Note [ATen preprocessor philosophy]

at::Tensor cudnn_convolution(
    const at::Tensor& input, const at::Tensor& weight,
    IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation,
    int64_t groups, bool benchmark, bool deterministic) {
  AT_ERROR("cudnn_convolution: ATen not compiled with cuDNN support");
}


  This file has been truncated. show original

  
  
    
    
  
  


I tried to probe the mkldnn file further but it points to some algorithm called -
‘ideep::algorithm::convolution_direct’, which seems to be defined in some Intel github account.
So I could not get to any code in which we can see the implementation of the convolution function directly - as in in terms of plain multiplication and addition.
Could anyone kindly suggest can/ how can we get to the base code in Pytorch?
Or can we assume that the implementation directly uses the given formula in torch.nn.conv2d to compute convolution?
Thanks in advance.