Hi, I am trying to modify the “torch/csrc/autograd/saved_variable.cpp” file, I call some python function in the file. I made the following modification:
#include <torch/csrc/python_headers.h>
#include <pybind11/pybind11.h>
#include <torch/csrc/utils/object_ptr.h>
#include <torch/csrc/autograd/python_variable.h>
#include <torch/csrc/Exceptions.h>
// original include
SavedVariable::SavedVariable(const Variable& variable, bool is_output, bool is_inplace_view)  {
auto mymodule = THPObjectPtr(PyImport_ImportModule(“mymodule”));
// prepare inputs
// call corresponding python functions
// get c++ object from python results
}
Which cmake file should I change to make it compile? If I do not change anything, it will throw the error “/home/ec2-user/pytorch/build/lib/libtorch_cpu.so: undefined reference to `PyInstanceMethod_Type’”
I think I need to link the python target and include the python lib somewhere, but where should I put it? Thanks a lot!