Is your feature request related to a problem? Please describe.
Run with a model exported in PyTorch I get this warning:
2019-04-23 12:00:27.1756880 [W:onnxruntime:CSharpOnnxRuntime, graph.cc:2193 onnxruntime::Graph::CleanUnusedInitializers] 1 exists in this graph's initializers but it is not used by any node
2019-04-23 12:00:27.1760419 [W:onnxruntime:CSharpOnnxRuntime, graph.cc:2193 onnxruntime::Graph::CleanUnusedInitializers] 2 exists in this graph's initializers but it is not used by any node
2019-04-23 12:00:27.1910954 [W:onnxruntime:InferenceSession, session_state_initializer.cc:500 onnxruntime::SaveInputOutputNamesToNodeMapping] Graph input with name 1 is not associated with a node.
2019-04-23 12:00:27.1915243 [W:onnxruntime:InferenceSession, session_state_initializer.cc:500 onnxruntime::SaveInputOutputNamesToNodeMapping] Graph input with name 2 is not associated with a node.
System information
Describe the solution you'd like
the exporter should clean unused initializes? or show a help on how to do that.
Describe alternatives you've considered
Manually clean the exported model, but I need documentation to know what I am doing
@spandantiwari : can you follow up on this for the pytorch exporter?
@dashesy - The unused initializers seems to be coming from the PyTorch model. There's a recent change that went in PyTorch master that may be relevant to this issue. Could you please try to export the model with do_constant_folding=True in the call to torch.onn.export API, and see if this issue is gone? Since the change went in PT master recently, you may have to get the latest nightly build for PT ( that you would need to install a latest nightly build (conda install pytorch-nightly-cpu -c pytorch).
@spandantiwari hi, thanks for your advice. i have tried it, it cleaned the unused initializers, but the function OrtSetSessionGraphOptimizationLevel can not work. i install the pytorch version is 1.1.0 nightly
my problem have been solved. i used onnx optimize my model, then the unused information was not shown again.
@mkwml can you share which optimization passes you tried? I would like to try an optimization with minimal change. eliminate_deadend looks promising.
@dashesy i used extract_constant_to_initializer and fuse_bn_into_conv optimization passes.
I had to use eliminate_unused_initializer:
import onnx
from onnx import optimizer
onnxfile = "model.onnx"
onnx_model = onnx.load(onnxfile)
passes = ["extract_constant_to_initializer", "eliminate_unused_initializer"]
optimized_model = optimizer.optimize(onnx_model, passes)
onnx.save(optimized_model, onnxfile)