Skip to content

Commit

Permalink
Fixed layout infer bug when some op is not in op_vector_ (#676)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
chenfeiyue-cfy authored Jan 11, 2024
1 parent 394cedc commit 0d8ca44
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tim/transform/mean_stddev_normalize_fusion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 0d8ca44

Please sign in to comment.