Skip to content

Commit 3bab156

Browse files
authored
Merge pull request #815 from cyfwry/809
fix the bug caused by vector.insert in torch_tensorrt::core::ir::get_…
2 parents 69c6c64 + 9a48020 commit 3bab156

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

core/ir/ir.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ c10::optional<at::ScalarType> get_value_first_calc_dtype_opt(torch::jit::Block*
5858
auto consumers = in->uses();
5959
auto search_list = std::vector<torch::jit::Use>(consumers.begin(), consumers.end());
6060

61-
for (auto& u : search_list) {
62-
auto n = u.user;
61+
for (auto iter = search_list.begin(); iter != search_list.end(); ++iter) {
62+
auto n = iter->user;
6363
LOG_GRAPH("Node we are looking at: " << util::node_info(n));
6464
auto ins = n->inputs();
6565
auto outs = n->outputs();
@@ -94,7 +94,9 @@ c10::optional<at::ScalarType> get_value_first_calc_dtype_opt(torch::jit::Block*
9494
for (auto o : outs) {
9595
if (o->type() == c10::TensorType::get()) {
9696
auto o_uses = o->uses();
97+
int offset = iter - search_list.begin();
9798
search_list.insert(search_list.end(), o_uses.begin(), o_uses.end());
99+
iter = search_list.begin() + offset;
98100
}
99101
}
100102
continue;
@@ -123,7 +125,9 @@ c10::optional<at::ScalarType> get_value_first_calc_dtype_opt(torch::jit::Block*
123125
for (auto o : outs) {
124126
if (o->type() == c10::TensorType::get()) {
125127
auto o_uses = o->uses();
128+
int offset = iter - search_list.begin();
126129
search_list.insert(search_list.end(), o_uses.begin(), o_uses.end());
130+
iter = search_list.begin() + offset;
127131
}
128132
}
129133
}
@@ -150,4 +154,4 @@ TypeMap get_block_first_calc_dtypes_opt(torch::jit::Block* b) {
150154

151155
} // namespace ir
152156
} // namespace core
153-
} // namespace torch_tensorrt
157+
} // namespace torch_tensorrt

0 commit comments

Comments
 (0)