If model use initializer, fuse_bn_into_conv is broken from v0.3.9
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 834
- Forks
- 109
- Avg merge
- 6h 55m
- Merged PRs (30d)
- 2
Description
I tried to optimize model by using "fuse_bn_into_conv", generate optimized model incorrectly from v0.3.9.
I would say 807cff7 is the cause. this commit would work fine with constant node, but the initializer shouldn't work...
Why were these changes made?
I'd like to support for initializer as well since onnxoptimizer has "extract_constant_to_initializer" which I often use to avoid errors related to topological sort. At least I wouldn't like this change.
Confirmed Environment(part of pyproject.toml)
[tool.poetry.dependencies]
python = "3.11"
onnx = "1.13.1"
onnxoptimizer = "0.3.9"
Reproduce Code
-
Download tiny-yolov3.onnx (this model is used initializer)
https://github.com/onnx/models/blob/main/vision/object_detection_segmentation/tiny-yolov3/model/tiny-yolov3-11.onnx -
prepare onnx and onnxoptimizer
-
create reproduce code
import onnx
from onnxoptimizer import optimize
# load model
model_path = "tiny-yolov3-11.onnx"
model = onnx.load(model_path)
# setting optimize passes
optimization_passes = ["fuse_bn_into_conv"]
# execute optimization
optimized_model = optimize(model, optimization_passes)
# save model
optimized_model_path = "tiny-yolov3-11-optimized.onnx"
onnx.save(optimized_model, optimized_model_path)
v0.3.9

in case of v0.3.8

Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Python reproduction with tiny-yolov3-11.onnx and compare fuse_bn_into_conv behavior between v0.3.8 and v0.3.9, focusing on commit 807cff7. Done means optimization handles models whose batch-normalization parameters are initializers without generating an incorrect ONNX model.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- machine-learning, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100