Fix bug in remove_imports (#1743)
* Fix bug in remove_imports IndexError: list index out of range error as `model.opset_import list` is changing dynamically * pre-commit fixpull/1753/head
parent
cadc2658f3
commit
e519898adb
mmdeploy/core/optimizers
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue