Skip to content

[Tensorflow] IndexError: list index (0) out of range #37

@peiwenhuang27

Description

@peiwenhuang27

Environment: Google Colaboratory
Tensorflow (official): 2.6.0
Neural Compressor: 1.7.2

Hi, I was quantizing a pre-trained Keras model (also in Tensorflow 2.6) with post training quantization method when the following error occurred:

2021-10-28 08:33:25 [INFO] Pass Quantization elapsed time: 9205.52 ms
2021-10-28 08:33:42 [INFO] Pass QuantizedRNNConverter elapsed time: 300.62 ms
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/adaptor/tensorflow.py", line 462, in quantize
    data_loader=data_loader).convert()
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/adaptor/tf_utils/graph_converter.py", line 249, in convert
    post_cse_graph_def = PostCseOptimizer(model.graph_def).do_transformation()
AttributeError: 'NoneType' object has no attribute 'graph_def'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/adaptor/tf_utils/graph_converter.py", line 571, in quantize
    self._fuse_requantize_with_fused_quantized_node()
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/adaptor/tf_utils/graph_converter.py", line 709, in _fuse_requantize_with_fused_quantized_node
    self._tmp_graph_def).do_transformation()
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/adaptor/tf_utils/graph_rewriter/int8/fuse_matmul_requantize.py", line 108, in do_transformation
    min_input_value = (min_input_node.attr['value'].tensor.float_val)[0]
IndexError: list index (0) out of range
2021-10-28 08:33:43 [ERROR] Fail to quantize graph due to list index (0) out of range.
2021-10-28 08:33:43 [ERROR] Unexpected exception AttributeError("'NoneType' object has no attribute 'graph_def'") happened during tuning.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/adaptor/tensorflow.py", line 462, in quantize
    data_loader=data_loader).convert()
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/adaptor/tf_utils/graph_converter.py", line 249, in convert
    post_cse_graph_def = PostCseOptimizer(model.graph_def).do_transformation()
AttributeError: 'NoneType' object has no attribute 'graph_def'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/experimental/quantization.py", line 151, in execute
    self.strategy.traverse()
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/strategy/strategy.py", line 333, in traverse
    tune_cfg, self.model, self.calib_dataloader, self.q_func)
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/utils/utility.py", line 240, in fi
    res = func(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/adaptor/tensorflow.py", line 475, in quantize
    data_loader=data_loader).convert()
  File "/usr/local/lib/python3.7/dist-packages/neural_compressor/adaptor/tf_utils/graph_converter.py", line 249, in convert
    post_cse_graph_def = PostCseOptimizer(model.graph_def).do_transformation()
AttributeError: 'NoneType' object has no attribute 'graph_def'
2021-10-28 08:33:43 [ERROR] Specified timeout or max trials is reached! Not found any quantized model which meet accuracy goal. Exit.
Traceback (most recent call last):
  File "main.py", line 115, in <module>
    evaluate_opt_graph.run()
  File "main.py", line 100, in run
    q_model.save(self.args.output_graph) 
AttributeError: 'NoneType' object has no attribute 'save'

The complete log is attached below.
error_log.txt

If helpful, please find the quantization config, pre-trained model and script here (please request access via email)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions