[Compiled Autograd] Remove TORCH_API from generated autograd nodes (#105286)

This works around the Windows symbol count issues in #103822.  Unfortunately, removing TORCH_API only works on Windows, but causes build issues on Linux, so we need the `#ifdef`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/105286
Approved by: https://github.com/albanD
This commit is contained in:
Jason Ansel
2023-07-25 09:30:04 -07:00
committed by PyTorch MergeBot
parent 952021934f
commit 457d01bcfd
8 changed files with 6 additions and 33 deletions

View File

@ -204,7 +204,6 @@ auto PyNode::name() const -> std::string {
return name;
}
#ifdef TORCH_COMPILED_AUTOGRAD
void PyNode::compiled_args(CompiledNodeArgs& args) {
static PyObject* method_name =
PyUnicode_InternFromString("_compiled_autograd_key");
@ -217,7 +216,7 @@ void PyNode::compiled_args(CompiledNodeArgs& args) {
auto size = PyTuple_GET_SIZE(pykey.get());
TORCH_INTERNAL_ASSERT(size > 0);
// first value is unique ID of the AotAutograd graph
ssize_t key = PyLong_AsSsize_t(PyTuple_GET_ITEM(pykey.get(), 0));
auto key = PyLong_AsSsize_t(PyTuple_GET_ITEM(pykey.get(), 0));
if (C10_UNLIKELY(key < 0)) {
TORCH_CHECK(PyErr_Occurred(), "key must be positive");
throw_python_error();
@ -272,7 +271,6 @@ variable_list PyNode::apply_with_saved(
saved.after(f->input_info);
return result;
}
#endif
} // namespace autograd
} // namespace torch