forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.cpp
31 lines (27 loc) · 895 Bytes
/
function.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#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