onnx / onnx/optimizer

Redundant initializers introduced to the models using eliminate passes.

Open
#176 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
834
Forks
109
Avg merge
6h 55m
Merged PRs (30d)
2

Description

I noticed an odd behavior, when using R-CNN models from ONNX Model Hub: The optimizer adds redundant initializer nodes to the models, in different passes (e.g., eliminate_shape_gather and eliminate_nop_reshape). Upon execution, they are removed and the models work, however the models get bloated this way and it would be nice to resolve this, as it has to do with eliminate passes which are part of the default optimization bundle.

Pass: eliminate_shape_gather, Model: Faster R-CNN R-50-FPN-int8, opset=12
2025-03-18 19:36:45.016246632 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2797'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016284009 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2473'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016317849 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2586'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016338868 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2561'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016384071 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2034'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016395604 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '1738'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016400882 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2555'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016446202 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2499'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016466860 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2476'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016477887 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2583'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016498564 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2505'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016528857 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2527'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016550868 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2479'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016557028 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2502'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016563560 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2530'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016569462 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2533'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016575731 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2558'. It is not used by any node and should be removed from the model.
2025-03-18 19:36:45.016582126 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '2589'. It is not used by any node and should be removed from the model.

Pass: eliminate_nop_reshape, Model: Faster R-CNN R-50-FPN-int8, opset=12
2025-03-18 19:37:51.308402762 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '823'. It is not used by any node and should be removed from the model.
2025-03-18 19:37:51.308431172 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '579'. It is not used by any node and should be removed from the model.
2025-03-18 19:37:51.308496786 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '640'. It is not used by any node and should be removed from the model.
2025-03-18 19:37:51.308506370 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '762'. It is not used by any node and should be removed from the model.
2025-03-18 19:37:51.308530685 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer '701'. It is not used by any node and should be removed from the model.

Similar results apply for "Faster R-CNN R-50-FPN-qdq.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the Faster R-CNN R-50-FPN-int8 ONNX Model Hub model at opset 12, then inspect the eliminate_shape_gather and eliminate_nop_reshape passes. Compare the model before and after each pass, focusing on the initializers reported by CleanUnusedInitializersAndNodeArgs. Done means the default optimization bundle no longer leaves redundant initializers in these models.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.