Skip to content

Fix the bug that fallback does not support more than one output #817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions core/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,21 @@ GraphAndMapping ConstructFallbackGraph(
}
}

for (auto& output : block->outputs()) {
if (old_to_new_g.count(output)) {
new_g->registerOutput(old_to_new_g[output]);
if (block->outputs().size() > 1) {
std::vector<torch::jit::Value*> fallback_graph_vector;
for (auto& output : block->outputs()) {
if (old_to_new_g.count(output)) {
fallback_graph_vector.push_back(old_to_new_g[output]);
}
}
torch::jit::ArrayRef<torch::jit::Value*> fallback_graph_outputs(fallback_graph_vector);
auto return_tuple_node = new_g->createTuple(fallback_graph_outputs);
new_g->block()->appendNode(return_tuple_node);
// Set the output as the produced tuple
new_g->registerOutput(return_tuple_node->outputs()[0]);
} else {
if (old_to_new_g.count(block->outputs()[0])) {
new_g->registerOutput(old_to_new_g[block->outputs()[0]]);
}
}
return {new_g, old_to_new_g};
Expand Down