Skip to content

Commit

Permalink
Use a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
soulitzer committed Nov 11, 2020
1 parent 1aac0d1 commit 8fbeea9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions torch/csrc/autograd/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,15 @@ auto Engine::execute(const edge_list& roots,
}

if (skip_dummy_node) {
auto inputs_ = std::vector<Variable>(graph_root->num_inputs() - 1);
inputs_.emplace(inputs_.begin() + roots.at(0).input_nr, inputs.at(0));
auto inputs_ = std::vector<Variable>();
inputs_.reserve(graph_root->num_inputs());
for (size_t i = 0; i < graph_root->num_inputs(); ++i) {
if (i == roots.at(0).input_nr) {
inputs_.emplace_back(inputs.at(0));
} else {
inputs_.emplace_back();
}
}
execute_with_graph_task(graph_task, graph_root, std::move(inputs_));
} else {
execute_with_graph_task(graph_task, graph_root);
Expand Down

0 comments on commit 8fbeea9

Please sign in to comment.