下载
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助
昇腾小AI

保存模型时提示“RuntimeError: cannot find shift_bit of layer ** in record_file”

问题描述

训练后量化场景,量化因子记录文件中无法找到某层的shift_bit字段,无法进行后续量化模型保存动作,量化流程终止。提示信息如下:

  File "test_tf_diff.py", line 1361, in test_AMCT15_TF_GPUCPU_GPUCPU_CALI_NUQ_DIFF_LEVEL1_TC_007
    save_model(model,out_puts, record_file, quant_path + model.split('/')[-1].split('.')[0])
  File "xx/lib/python3.x/site-packages/amct_tensorflow/common/utils/check_params.py", line 43, in wrapper
    return func(*args, **kwargs)
  File "xx/lib/python3.x/site-packages/amct_tensorflow/interface/save_model.py", line 71, in save_model
    save_model_inner(pb_model, outputs, record_file, save_path)
  File "xx/lib/python3.x/site-packages/amct_tensorflow/interface/save_model.py", line 110, in save_model_inner
    layers_params, skip_fusion_layers = record_parser.parse(SHIFT_N_ENABLE)
  File "xx/lib/python3.x/site-packages/amct_tensorflow/common/utils/parse_record_file.py", line 130, in parse
    layer_params = recorder.parse_quant_value(enable_shift_n)
  File "xx/lib/python3.x/site-packages/amct_tensorflow/common/utils/parse_record_file.py", line 206, in parse_quant_value
    enable_shift_n and self.node.type in self.shift_n_types))
  File "xx/lib/python3.x/site-packages/amct_tensorflow/common/utils/parse_record_file.py", line 358, in get_shift_n
    (self.get_key()))
RuntimeError: cannot find shift_bit of layer conv1/Conv2d in record_file

可能原因

网络的尾层节点为量化节点时,如果量化推理时不修改推理的输出节点,则会导致该问题。此场景下,调用quantize_model时,会有warning信息提示输出节点发生变化。

处理建议

该场景下调用quantize_model时,会有warning信息提示输出节点发生变化,在执行校准的过程中,根据提示信息,修改输出节点即可。

搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词