Files
pytorch/torch/csrc/dynamo/compiled_autograd.cpp
cyyever 24ca7e91e6 [1/N] Use internal linkage in torch/csrc C++ files. (#150930)
Turn more functions and variables into static if they are not used outside the cpp files. Unused functions are removed.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/150930
Approved by: https://github.com/Skylion007

Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
2025-04-11 02:19:31 +00:00

30 lines
930 B
C++

#include <torch/csrc/autograd/engine.h>
#include <torch/csrc/dynamo/compiled_autograd.h>
namespace torch::dynamo::autograd {
static std::unique_ptr<PyCompilerInterface> kActivePyCompilerInterface;
const std::unique_ptr<PyCompilerInterface>& getPyCompilerInterface() {
TORCH_INTERNAL_ASSERT(kActivePyCompilerInterface != nullptr);
return kActivePyCompilerInterface;
}
PyCompilerGuard::PyCompilerGuard(std::unique_ptr<PyCompilerInterface>&& impl) {
TORCH_INTERNAL_ASSERT(
kActivePyCompilerInterface == nullptr && impl != nullptr);
kActivePyCompilerInterface = std::move(impl);
}
PyCompilerGuard::~PyCompilerGuard() {
TORCH_INTERNAL_ASSERT(kActivePyCompilerInterface != nullptr);
kActivePyCompilerInterface.reset();
}
std::vector<std::optional<InputMetadata>> get_input_metadata(
const edge_list& edges) {
return torch::autograd::collect_input_metadata(edges);
}
} // namespace torch::dynamo::autograd