How to call C++ Kernels independently

I have installed PyTorch from source. Now, I want to use the CPU Maxpool implementation which is in “aten/src/ATen/native/cpu/MaxPoolKernel.cpp” directly. So basically I want to write a code which calls this maxpool function directly and try giving various kinds of inputs to it, but I’m having problems with it. What is the correct way to do this? I also would like to try this for other operations as well later.

What I tried was that I first created a .h file for MaxPool which somehow is there for MaxUnpool but not MaxPool. Then I wrote a code which included the .h file and then called the function from my code. The problem is there are multiple other includes inside these files as well for which the path is not getting set correctly hence I get the error of file not found.

I’m unsure what your exact use case is but you might want to use the C++ frontend via e.g.:

auto model = torch::nn::MaxPool2d(kernel_size=[5, 5], stride=[5, 5], padding=[0, 0], dilation=[1, 1], ceil_mode=false);
auto x =  torch::ones({1, 1, 25, 25}, torch::requires_grad());
auto y = model(x);

which would then call into these layers.