Open michaelnguyen11 opened 2 years ago
@michaelnguyen11, it is because the tensor '482' is an empty tensor. Its size is 0. Why do you Concat an empty tensor though? It is useless.
Hi @yufenglee ,
Thanks for the information. I converted from Pytorch model to ONNX model , don't know why an empty tensor exists in ONNX model.
I'll check it the conversation again and remove unused tensor.
Hi @yufenglee m
I used pull request https://github.com/microsoft/onnxruntime/pull/9640 , it worked well and I can quantize the model.
However it have 2 problems : 1/ The output of quantized model is worse than original model.
2/ I get a bunch of warnings like the following:
2021-11-02 11:43:38.539284273 [W:onnxruntime:, graph.cc:3391 CleanUnusedInitializers] Removing initializer '2249_quantized_scale'. It is not used by any node and should be removed from the model.
2021-11-02 11:43:38.539307329 [W:onnxruntime:, graph.cc:3391 CleanUnusedInitializers] Removing initializer '2246_quantized_zero_point'. It is not used by any node and should be removed from the model.
2021-11-02 11:43:38.539313971 [W:onnxruntime:, graph.cc:3391 CleanUnusedInitializers] Removing initializer '2246_quantized_scale'. It is not used by any node and should be removed from the model.
2021-11-02 11:43:38.539319817 [W:onnxruntime:, graph.cc:3391 CleanUnusedInitializers] Removing initializer '2243_quantized_zero_point'. It is not used by any node and should be removed from the model.
2021-11-02 11:43:38.539325362 [W:onnxruntime:, graph.cc:3391 CleanUnusedInitializers] Removing initializer '2243_quantized_scale'. It is not used by any node and should be removed from the model.
2021-11-02 11:43:38.539331112 [W:onnxruntime:, graph.cc:3391 CleanUnusedInitializers] Removing initializer '2240_quantized_scale'. It is not used by any node and should be removed from the model.
2021-11-02 11:43:38.539338720 [W:onnxruntime:, graph.cc:3391 CleanUnusedInitializers] Removing initializer '2147_quantized_zero_point'. It is not used by any node and should be removed from the model.
2021-11-02 11:43:38.539346504 [W:onnxruntime:, graph.cc:3391 CleanUnusedInitializers] Removing initializer '2144_quantized_zero_point'. It is not used by any node and should be removed from the model.
2021-11-02 11:43:38.539352945 [W:onnxruntime:, graph.cc:3391 CleanUnusedInitializers] Removing initializer '2144_quantized_scale'. It is not used by any node and should be removed from the model.
Could you please help me how to remove it ? I tried a solution in https://github.com/microsoft/onnxruntime/issues/1899 , but I got a coredump when follow that solution. The code that I used:
import onnx
import onnxoptimizer
onnxfile = 'realtimeStereo_quant.onnx'
onnx_model = onnx.load(onnxfile)
passes = ["extract_constant_to_initializer", "eliminate_unused_initializer"]
optimized_model = onnxoptimizer.optimize(onnx_model, passes)
onnx.save(optimized_model, onnxfile)
This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details.
Describe the bug We converted a Pytorch model to ONNX model. The ONNX model can inference with OnnxRuntime. Now We want to quantize that model to run on mobile device, so I used static quantization method to quantize that model. However the quantization process is failed with error code :
Dived into debug this, I found that : because raw_data of that weight name is empty, therefore the data passed to quantize_data function is empty, hence min() function error.
Print all nodes of ONNX model, raw data of this weight name is empty.
Urgency Yes, this model is our release in Q4/2021. So we need to fix it as soon as possible.
System information
To Reproduce My quantization code:
Run : python3 quantize_cpu.py --input_model realtimeStereo.onnx --output_model realtimeStereo_quant.onnx --calibrate_dataset ./test_images
Attached test_images and onnx model : test_images.zip
Expected behavior Conversion should complete as normal.