Skip to content

Commit 2cf1183

Browse files
Mikhail Zolotukhinfacebook-github-bot
authored andcommitted
Use optimized graph in Inline (essentially, making Inline recursive now). (pytorch#26489)
Summary: Pull Request resolved: pytorch#26489 This basically fixes Inline(recurse=true) and makes it a default. One reservation against running inlining recursively in the original implementation was that we might hit a quadratic behavior, but in this implementation it's not an issue since we're inlining only already inlined graphs and as we recursively descend the call tree we're caching graphs we've already optimized. Test Plan: Imported from OSS Differential Revision: D17485744 Pulled By: ZolotukhinM fbshipit-source-id: 2ed7bdc69863b90a8c10a385d63f8e7c9e7b05f5
1 parent c522b63 commit 2cf1183

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

test/cpp/jit/test_inliner.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ void testInliner() {
4747

4848
auto g = fn.graph();
4949
Inline(*g);
50-
FileCheck()
51-
.check("three")
52-
->check("two")
53-
->check_count("prim::CallFunction", 1)
54-
->run(*g);
50+
FileCheck().check_count("prim::Print", 3)->run(*g);
5551
}
5652
}
5753
} // namespace jit

torch/csrc/jit/passes/inliner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ void inlineCalls(Block* block) {
2020
auto fun_type =
2121
function_constant->output()->type()->expect<FunctionType>();
2222
cur->removeInput(0);
23-
inlineCallTo(cur, *fun_type->function()->graph());
23+
inlineCallTo(cur, *fun_type->function()->optimized_graph());
2424
} break;
2525
case prim::CallMethod: {
2626
const std::string& name = cur->s(attr::name);
2727
if (auto class_type = cur->input(0)->type()->cast<ClassType>()) {
2828
auto function = class_type->getMethod(name);
29-
inlineCallTo(cur, *function->graph());
29+
inlineCallTo(cur, *function->optimized_graph());
3030
}
3131
} break;
3232
default: {

0 commit comments

Comments
 (0)