Fixed layout infer bug when some op is not in op_vector_ (#676)
Backgroud: instance_norm models run crash after latest lay out code refine Reason: erase() function will delete the last element if the param is vector.end() Solution: Check iterator validtion before erase. Type: Bug Fix Issue: 37449 Signed-off-by: Feiyue Chen <Feiyue.Chen@verisilicon.com>
This commit is contained in:
parent
394cedcfe6
commit
0d8ca44377
|
|
@ -109,12 +109,14 @@ void RemoveTensorsAndOps(
|
|||
std::shared_ptr<vx::Graph>& graph,
|
||||
const std::vector<std::shared_ptr<vx::Operation>>& norm_ops) {
|
||||
for (uint32_t i = 0; i < norm_ops.size(); i++) {
|
||||
auto it =
|
||||
auto it =
|
||||
std::remove_if(graph->OpVector().begin(), graph->OpVector().end(),
|
||||
[norm_ops, i](std::shared_ptr<vx::Operation> oper) {
|
||||
return oper == norm_ops[i];
|
||||
});
|
||||
graph->OpVector().erase(it); //Remove current op from op_vector_
|
||||
if (it != graph->OpVector().end()) {
|
||||
graph->OpVector().erase(it);
|
||||
} // Remove current op from op_vector_
|
||||
auto input_tensors = norm_ops[i]->impl()->InputsTensor();
|
||||
auto output_tensors = norm_ops[i]->impl()->OutputsTensor();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue