quic / aimet

AIMET is a library that provides advanced quantization and compression techniques for trained neural network models.
https://quic.github.io/aimet-pages/index.html
Other
2.08k stars 373 forks source link

Error while exporting quantsim encodings. #2556

Open surajpandey353 opened 10 months ago

surajpandey353 commented 10 months ago

Hi,

I was trying range learning with Aimet Torch 1.28.1 same as in the tutorial as task zero, in order to see if I am able to export the model successfully or not. Onnx export works fine, but quantsim encoding (json file) doesn't export. The error is quite understandable, but I couldn't make out what part is problematic for export. If someone could help me understand which part is creating problem.

Error:

Traceback (most recent call last):
  File "aimet_ptq.py", line 236, in <module>
    main(**vars(args))
  File "aimet_ptq.py", line 223, in main
    quantsim.export(path=export_path, filename_prefix='quant_encoded', dummy_input=torch.randn(input_shape), onnx_export_args=onnx_export_args)
  File "anaconda3/envs/aimet/lib/python3.8/site-packages/aimet_torch/quantsim.py", line 431, in export
    self.export_onnx_model_and_encodings(path, filename_prefix, model_to_export, self.model,
  File "anaconda3/envs/aimet/lib/python3.8/site-packages/aimet_torch/quantsim.py", line 511, in export_onnx_model_and_encodings
    QuantizationSimModel._export_encodings_to_files(sim_model, path, filename_prefix,
  File "anaconda3/envs/aimet/lib/python3.8/site-packages/aimet_torch/quantsim.py", line 768, in _export_encodings_to_files
    QuantizationSimModel._update_encoding_dicts_for_layer(layer, layer_name, activation_encodings_onnx,
  File "anaconda3/envs/aimet/lib/python3.8/site-packages/aimet_torch/quantsim.py", line 917, in _update_encoding_dicts_for_layer
    QuantizationSimModel._update_encoding_dict_for_output_activations(layer, layer_name,
  File "anaconda3/envs/aimet/lib/python3.8/site-packages/aimet_torch/quantsim.py", line 990, in _update_encoding_dict_for_output_activations
    output_tensors, propagate_tensors = QuantizationSimModel._get_layer_activation_tensors(layer_name,
  File "anaconda3/envs/aimet/lib/python3.8/site-packages/aimet_torch/quantsim.py", line 1125, in _get_layer_activation_tensors
    intermediate_tensors.extend(op_to_io_tensor_map[name].outputs)
AttributeError: 'list' object has no attribute 'outputs'
quic-mangal commented 10 months ago

Hi @surajpandey353, could you provide some details about the model you are using?

surajpandey353 commented 9 months ago

Hi @quic-mangal,

Apologies for the delay. I am using a custom model with few conv layers, gru and activations as a toy-example to see if I am able to export and use the model. Unfortunately, I am unable to debug this error.

Here is how the netron graph looks like. toy_example