GraphProto loses its sparse tensor initializer going through the optimizer.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 834
- Forks
- 109
- Avg merge
- 6h 55m
- Merged PRs (30d)
- 2
Description
Bug Report
Is the issue related to model conversion?
No.
Describe the bug
Start with an ONNX model with a sparse initializer. Run model optimizer with option "eliminate_unused_initializer". Now the returned model no longer has the original sparse initializer.
System information
- OS Platform and Distribution (e.g. Linux Ubuntu 16.04): Linux RedHat5
- ONNX version (e.g. 1.7): 1.6
- Python version: 3.8.2
- GCC/Compiler version (if compiling from source): gcc7
- CMake version:
- Protobuf version: 3
- Visual Studio version (if applicable):
Reproduction instructions
- Describe the code to reproduce the behavior.
import onnx
from onnx import optimizer
model = onnx.load('model.onnx')
model.graph.sparse_initializer
optimized_model = optimizer.optimize(model)
optimized_model.graph.sparse_initializer
- Attach the ONNX model to the issue (where applicable)
A text version of the ONNX model is attached.
Expected behavior
The sparse initializer should persist in the optimized model.
Notes
When the optimizer converts GraphProto to onnx::Graph in the following stack, the sparse initializer is not carried over:
#0 onnx::graphProtoToGraph (gp=..., nested=nested@entry=false)
at .../onnx/common/ir_pb_converter.cc:188
onnx/onnx#1 0x0000000000568d3f in onnx::ImportModelProto (mp=...)
at .../onnx/common/ir_pb_converter.cc:338
onnx/onnx#2 0x000000000054e39a in onnx::optimization::Optimizer::optimize (
this=this@entry=0x7fffffffcf00, mp_in=...)
at .../onnx/optimizer/optimize.h:26
onnx/onnx#3 0x0000000000534d3c in onnx::optimization::Optimize (mp_in=..., names=...)
at .../onnx/optimizer/optimize.cc:32
rank2-identity.txt
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 at onnx/common/ir_pb_converter.cc:188 and follow the GraphProto-to-Graph conversion used by onnx/optimizer/optimize.h and optimize.cc. Run the supplied Python reproduction with the attached model and verify that the sparse initializer remains in optimized_model.graph.sparse_initializer when elimination is enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100