mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/22202 ghimport-source-id: de6c963af1df76d2d6357155e64a5913ab879f76 Test Plan: Imported from OSS Differential Revision: D15998761 Pulled By: suo fbshipit-source-id: 5414a6424953738d823b265d20dc67dde6e5b2d8
32 lines
895 B
C++
32 lines
895 B
C++
#include <torch/csrc/jit/function.h>
|
|
|
|
#include <torch/csrc/jit/script/error_report.h>
|
|
|
|
namespace torch {
|
|
namespace jit {
|
|
struct RecursiveMethodCallError : public std::exception {};
|
|
void placeholderCreator(Function&) {
|
|
throw RecursiveMethodCallError();
|
|
}
|
|
|
|
void Function::ensure_defined() {
|
|
try {
|
|
if (function_creator_) {
|
|
auto creator = function_creator_;
|
|
function_creator_ = placeholderCreator;
|
|
creator(*this);
|
|
function_creator_ = nullptr;
|
|
}
|
|
} catch (RecursiveMethodCallError&) {
|
|
throw script::ErrorReport() // TODO: once lower_first_class methods is
|
|
// removed re-establish callsite info for
|
|
// debugging
|
|
<< " method '" << name() << "' is called recursively. "
|
|
<< "Recursive calls are not supported";
|
|
}
|
|
check_single_output();
|
|
}
|
|
|
|
} // namespace jit
|
|
} // namespace torch
|