6 #include <torch/csrc/jit/ir.h> 7 #include <torch/csrc/jit/script/error_report.h> 8 #include <torch/csrc/jit/script/module.h> 9 #include <torch/csrc/jit/script/sugared_value.h> 10 #include <torch/csrc/jit/script/tree_views.h> 16 using Resolver = std::function<std::shared_ptr<
17 SugaredValue>(
const std::string& name, Method& m,
const SourceRange& loc)>;
19 inline std::shared_ptr<SugaredValue> nativeResolver(
20 const std::string& name,
22 const SourceRange& loc) {
23 if (name ==
"torch") {
24 return std::make_shared<BuiltinModule>(
"aten");
37 explicit Self(std::shared_ptr<SugaredValue> sugared)
38 : sugared_(std::move(sugared)) {}
39 explicit Self(ClassTypePtr type) : firstClass_(std::move(type)) {}
41 ClassTypePtr asFirstClass()
const {
44 std::shared_ptr<SugaredValue> asSugared()
const {
51 std::shared_ptr<SugaredValue> sugared_ =
nullptr;
53 ClassTypePtr firstClass_ =
nullptr;
56 TORCH_API
void defineMethodsInModule(
57 const std::shared_ptr<Module>& m,
58 const std::vector<Def>& definitions,
59 const std::vector<Resolver>& resolvers,
65 TORCH_API
void defineMethodsInModule(
66 const std::shared_ptr<Module>& m,
67 const std::string& source,
68 const Resolver& resolver,
71 TORCH_API
void lambdaLiftFork(
Node* fork_node);