Skip to content

Commit 504c14e

Browse files
committed
[Core] refactor ModelWrapper.del_initializer to use get_by_name
1 parent 5269aa6 commit 504c14e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/qonnx/core/modelwrapper.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,9 @@ def get_initializer(self, tensor_name, return_dtype=False):
370370
def del_initializer(self, initializer_name):
371371
"""Deletes an initializer from the model."""
372372
graph = self._model_proto.graph
373-
for init in graph.initializer:
374-
if init.name == initializer_name:
375-
graph.initializer.remove(init)
376-
break
373+
init = util.get_by_name(graph.initializer, initializer_name)
374+
if not (init is None):
375+
graph.initializer.remove(init)
377376

378377
def find_producer(self, tensor_name):
379378
"""Finds and returns the node that produces the tensor with given name."""

0 commit comments

Comments
 (0)