Skip to content

Commit

Permalink
Fix bug in remove_imports (open-mmlab#1743)
Browse files Browse the repository at this point in the history
* Fix bug in remove_imports

IndexError: list index out of range error as `model.opset_import list` is changing dynamically

* pre-commit fix
  • Loading branch information
eugene123tw authored and goodsong81 committed Feb 13, 2023
1 parent 336076e commit 2273a30
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mmdeploy/core/optimizers/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def remove_imports(model: onnx.ModelProto):
for node in model.graph.node:
if hasattr(node, 'module') and (node.module not in dst_domain):
dst_domain.append(node.module)
src_domains = [oi.domain for oi in model.opset_import]
src_domains = [oi for oi in model.opset_import]
for i, src_domain in enumerate(src_domains):
if src_domain not in dst_domain:
if src_domain.domain not in dst_domain:
logger.info(f'remove opset_import {src_domain}')
model.opset_import.pop(i)
model.opset_import.remove(src_domain)

0 comments on commit 2273a30

Please sign in to comment.