Skip to content

fix the bug caused by vector.insert in torch_tensorrt::core::ir::get_… #815

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 1 commit into from
Feb 14, 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
10 changes: 7 additions & 3 deletions core/ir/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ c10::optional<at::ScalarType> get_value_first_calc_dtype_opt(torch::jit::Block*
auto consumers = in->uses();
auto search_list = std::vector<torch::jit::Use>(consumers.begin(), consumers.end());

for (auto& u : search_list) {
auto n = u.user;
for (auto iter = search_list.begin(); iter != search_list.end(); ++iter) {
auto n = iter->user;
LOG_GRAPH("Node we are looking at: " << util::node_info(n));
auto ins = n->inputs();
auto outs = n->outputs();
Expand Down Expand Up @@ -94,7 +94,9 @@ c10::optional<at::ScalarType> get_value_first_calc_dtype_opt(torch::jit::Block*
for (auto o : outs) {
if (o->type() == c10::TensorType::get()) {
auto o_uses = o->uses();
int offset = iter - search_list.begin();
search_list.insert(search_list.end(), o_uses.begin(), o_uses.end());
iter = search_list.begin() + offset;
}
}
continue;
Expand Down Expand Up @@ -123,7 +125,9 @@ c10::optional<at::ScalarType> get_value_first_calc_dtype_opt(torch::jit::Block*
for (auto o : outs) {
if (o->type() == c10::TensorType::get()) {
auto o_uses = o->uses();
int offset = iter - search_list.begin();
search_list.insert(search_list.end(), o_uses.begin(), o_uses.end());
iter = search_list.begin() + offset;
}
}
}
Expand All @@ -150,4 +154,4 @@ TypeMap get_block_first_calc_dtypes_opt(torch::jit::Block* b) {

} // namespace ir
} // namespace core
} // namespace torch_tensorrt
} // namespace torch_tensorrt