专栏算法工具链测试reduce_mean, reduce_max等算子报错

测试reduce_mean, reduce_max等算子报错

已解决
XR2024-11-05
103
8

用户您好,请详细描述您所遇到的问题,详细的描述有助于帮助我们快速定位,解决问题~Thanks♪(・ω・)ノ

1. 芯片型号:J6E

2. 天工开物开发包 OpenExplorer 版本: J6_OE_V3.0.17

3. 问题定位:例如模型转换

4. 问题具体描述:使用01_check.sh脚本测试onnx opset 18中的标准算子reduce_mean, reduce_max报错,报错内容如下:

2024-11-05 10:49:24,135 file: tool_utils.py func: tool_utils line No: 81 log will be stored in /open_explorer/hb_compile.log

2024-11-05 10:49:24,135 file: hb_compile.py func: hb_compile line No: 376 Start hb_compile...

2024-11-05 10:49:24,135 file: hb_compile.py func: hb_compile line No: 377 hbdk version: 4.0.25

2024-11-05 10:49:24,135 file: hb_compile.py func: hb_compile line No: 378 horizon_nn version: 2.0.4

2024-11-05 10:49:24,136 file: hb_compile.py func: hb_compile line No: 379 hb_compile version: 3.2.4

2024-11-05 10:49:24,148 file: yaml_builder.py func: yaml_builder line No: 71 {'model_parameters': {'layer_out_dump': False, 'working_dir': '.hb_compile'}, 'input_parameters': {'input_name': '', 'input_shape': '', 'input_space_and_range': '', 'input_type_rt': 'featuremap', 'input_type_train': 'featuremap', 'norm_type': 'no_preprocess'}, 'calibration_parameters': {'calibration_type': 'skip', 'per_channel': False, 'run_on_bpu': '', 'run_on_cpu': ''}, 'compiler_parameters': {'compile_mode': 'latency', 'core_num': 1, 'debug': True, 'jobs': 32, 'max_time_per_fc': 0, 'optimize_level': 'O0'}}

2024-11-05 10:49:24,148 file: yaml_builder.py func: yaml_builder line No: 72 check template yaml load success

2024-11-05 10:49:24,148 file: yaml_builder.py func: yaml_builder line No: 220 Updated yaml config info: {'model_parameters': {'layer_out_dump': False, 'working_dir': '/open_explorer/.hb_compile', 'onnx_model': '/open_explorer/reduce_max.onnx', 'march': 'nash-e', 'output_model_file_prefix': 'reduce_max'}, 'input_parameters': {'input_name': 'data;axes', 'input_shape': '3x2x2;1', 'input_space_and_range': '', 'input_type_rt': 'featuremap;featuremap', 'input_type_train': 'featuremap;featuremap', 'norm_type': 'no_preprocess;no_preprocess'}, 'calibration_parameters': {'calibration_type': 'skip', 'per_channel': False, 'run_on_bpu': '', 'run_on_cpu': ''}, 'compiler_parameters': {'compile_mode': 'latency', 'core_num': 1, 'debug': True, 'jobs': 32, 'max_time_per_fc': 0, 'optimize_level': 'O0'}}

2024-11-05 10:49:24,151 file: hb_compile.py func: hb_compile line No: 37 Start verifying yaml

2024-11-05 10:49:24,156 file: params_parser.py func: params_parser line No: 157 Using onnx model file: /open_explorer/reduce_max.onnx

2024-11-05 10:49:24,156 file: onnx_parser.py func: onnx_parser line No: 39 Model input names: ['data', 'axes']

2024-11-05 10:49:24,156 file: params_parser.py func: params_parser line No: 167 Model has 2 inputs according to model file

2024-11-05 10:49:24,156 file: params_parser.py func: params_parser line No: 323 node_dict: {}

2024-11-05 10:49:24,156 file: params_parser.py func: params_parser line No: 416 Input shape [3, 2, 2] has length: 3, make sure it is a featuremap input

2024-11-05 10:49:24,156 file: params_parser.py func: params_parser line No: 416 Input shape [1] has length: 1, make sure it is a featuremap input

2024-11-05 10:49:24,156 file: params_parser.py func: params_parser line No: 661 Parameter calibration_type is skip. cal_data_dir check skipped

2024-11-05 10:49:24,156 file: params_parser.py func: params_parser line No: 793 Input node data's input_source not set, it will be set to None by default

2024-11-05 10:49:24,156 file: params_parser.py func: params_parser line No: 793 Input node axes's input_source not set, it will be set to None by default

2024-11-05 10:49:24,156 file: params_parser.py func: params_parser line No: 855 Parameter compile_mode is set to latency, balance_factor will set to 100.

2024-11-05 10:49:24,157 file: params_parser.py func: params_parser line No: 895 custom_op does not exist, skipped

2024-11-05 10:49:24,157 file: hb_compile.py func: hb_compile line No: 40 End verifying yaml

2024-11-05 10:49:24,157 file: ptq_model_builder.py func: ptq_model_builder line No: 241 quantize_params is {'cali_dict': {'calibration_type': 'max', 'quant_config': None}, 'input_dict': {'data': {'input_shape': [3, 2, 2]}, 'axes': {'input_shape': [1]}}, 'node_dict': {}, 'debug_methods': [], 'output_nodes': [], 'optimization_methods': None, 'quant_config': None}

2024-11-05 10:49:24,157 file: wrap_utils.py func: wrap_utils line No: 15 Start to execute horizon_nn.api.build_model.

2024-11-05 10:49:24,157 file: model_builder.py func: model_builder line No: 32 Start to Horizon NN Model Convert.

2024-11-05 10:49:24,157 file: model_debugger.py func: model_debugger line No: 66 Loading horizon_nn debug methods:[]

2024-11-05 10:49:24,157 file: model_builder.py func: model_builder line No: 189 The specified model compilation architecture: nash.

2024-11-05 10:49:24,157 file: model_builder.py func: model_builder line No: 193 The specified model compilation optimization parameters: [].

2024-11-05 10:49:24,157 file: model_builder.py func: model_builder line No: 32 Start to prepare the onnx model.

2024-11-05 10:49:24,158 file: prepare.py func: prepare line No: 145 Input ONNX Model Information:

ONNX IR version:     8

Opset version:      ['ai.onnx v18', 'horizon v1']

Producer:         backend-test

Domain:          None

Model version:      None

Graph input:

  data:         shape=[3, 2, 2], dtype=FLOAT32

  axes:         shape=[1], dtype=INT64

Graph output:

  reduced:       shape=[3, 1, 2], dtype=FLOAT32

2024-11-05 10:49:24,168 file: prepare.py func: prepare line No: 42 The original model's opset version is 18, try converting to opset 19.

2024-11-05 10:49:24,172 file: model_builder.py func: model_builder line No: 35 End to prepare the onnx model.

2024-11-05 10:49:24,172 file: model_builder.py func: model_builder line No: 239 Saving model to: /open_explorer/.hb_compile/reduce_max_original_float_model.onnx.

2024-11-05 10:49:24,172 file: model_builder.py func: model_builder line No: 32 Start to optimize the onnx model.

2024-11-05 10:49:24,174 file: model_builder.py func: model_builder line No: 35 End to optimize the onnx model.

2024-11-05 10:49:24,175 file: model_builder.py func: model_builder line No: 239 Saving model to: /open_explorer/.hb_compile/reduce_max_optimized_float_model.onnx.

2024-11-05 10:49:24,175 file: model_builder.py func: model_builder line No: 32 Start to calibrate the model.

2024-11-05 10:49:24,176 file: calibration_data_set.py func: calibration_data_set line No: 82 input name: data, number_of_samples: 1

2024-11-05 10:49:24,176 file: calibration_data_set.py func: calibration_data_set line No: 82 input name: axes, number_of_samples: 1

2024-11-05 10:49:24,176 file: calibration_data_set.py func: calibration_data_set line No: 96 There are 1 samples in the calibration data set.

2024-11-05 10:49:24,176 file: fixed_calibrater.py func: fixed_calibrater line No: 31 Run calibration model with fixed thresholds method.

2024-11-05 10:49:24,178 file: model_builder.py func: model_builder line No: 35 End to calibrate the model.

2024-11-05 10:49:24,179 file: model_builder.py func: model_builder line No: 239 Saving model to: /open_explorer/.hb_compile/reduce_max_calibrated_model.onnx.

2024-11-05 10:49:24,179 file: model_builder.py func: model_builder line No: 32 Start to precompile the model.

2024-11-05 10:49:24,183 file: model_builder.py func: model_builder line No: 35 End to precompile the model.

2024-11-05 10:49:24,184 file: model_builder.py func: model_builder line No: 239 Saving model to: /open_explorer/.hb_compile/reduce_max_ptq_model.onnx.

2024-11-05 10:49:24,203 file: model_builder.py func: model_builder line No: 35 End to Horizon NN Model Convert.

2024-11-05 10:49:24,203 file: wrap_utils.py func: wrap_utils line No: 18 End to execute horizon_nn.api.build_model.

2024-11-05 10:49:24,203 file: wrap_utils.py func: wrap_utils line No: 15 Start to execute hbdk.export.

2024-11-05 10:49:24,204 file: tool_utils.py func: tool_utils line No: 139 exception in command: main

2024-11-05 10:49:24,205 file: tool_utils.py func: tool_utils line No: 140 Traceback (most recent call last):

 File "/usr/local/lib/python3.10/dist-packages/horizon_tc_ui/utils/wrap_utils.py", line 17, in wrapper

  result = func(*args, **kwargs)

 File "/usr/local/lib/python3.10/dist-packages/horizon_tc_ui/hbir_handle.py", line 54, in export_hbir

  return export(proto=ptq_model, name=output_prefix_name)

 File "/usr/local/lib/python3.10/dist-packages/hbdk4/compiler/onnx/__init__.py", line 40, in export

  graph.emit_mlir_func_op(OpConvertorRegistry(), True)

 File "/usr/local/lib/python3.10/dist-packages/hbdk4/compiler/frontend/adaptor.py", line 350, in emit_mlir_func_op

  node_adaptor.emit_mlir_op(registry)

 File "/usr/local/lib/python3.10/dist-packages/hbdk4/compiler/frontend/adaptor.py", line 203, in emit_mlir_op

  raise e

 File "/usr/local/lib/python3.10/dist-packages/hbdk4/compiler/frontend/adaptor.py", line 188, in emit_mlir_op

  results = cvt.emit_mlir_op(self, *args, **kwargs)

 File "/usr/local/lib/python3.10/dist-packages/hbdk4/compiler/onnx/opset18.py", line 36, in emit_mlir_op

  axes = adaptor.operands[1].value.tolist()

AttributeError: 'hbdk4.compiler._mlir_libs._mlir.ir.BlockArgument' object has no attribute 'tolist'


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

 File "/usr/local/lib/python3.10/dist-packages/horizon_tc_ui/utils/tool_utils.py", line 137, in __decorator

  func(*args, **kargs)

 File "/usr/local/lib/python3.10/dist-packages/horizon_tc_ui/hb_compile.py", line 399, in main

  check_mode(model, proto, march, input_shape)

 File "/usr/local/lib/python3.10/dist-packages/horizon_tc_ui/hb_compile.py", line 338, in check_mode

  hbm_build(conf, ptq_model)

 File "/usr/local/lib/python3.10/dist-packages/horizon_tc_ui/hb_compile.py", line 239, in hbm_build

  hbm_builder.build()

 File "/usr/local/lib/python3.10/dist-packages/horizon_tc_ui/compile/hbm_builder.py", line 234, in build

  self.convert_model()

 File "/usr/local/lib/python3.10/dist-packages/horizon_tc_ui/compile/hbm_builder.py", line 196, in convert_model

  model = HBIRHandle.export_hbir(

 File "/usr/local/lib/python3.10/dist-packages/horizon_tc_ui/utils/wrap_utils.py", line 22, in wrapper

  raise ValueError(f"*** ERROR-OCCUR-DURING {module_info} ***," +

ValueError: *** ERROR-OCCUR-DURING hbdk.export ***, error message: 'hbdk4.compiler._mlir_libs._mlir.ir.BlockArgument' object has no attribute 'tolist'


2024-11-05 10:49:24,205 file: tool_utils.py func: tool_utils line No: 141 *** ERROR-OCCUR-DURING hbdk.export ***, error message: 'hbdk4.compiler._mlir_libs._mlir.ir.BlockArgument' object has no attribute 'tolist'

请问如何解决?


算法工具链
评论2
0/1000
  • Huanghui
    Lv.5

    你好,测试模型有两个问题是目前工具链版本不支持的:

    1. opset: 目前支持的版本opset=10-19

    2. input tensor的type是bool类型的,目前工具链的input type不支持该类型哈。

    2024-11-06
    0
    5
    • XR回复Huanghui:

      您好,我测试的reduce_max版本是opset 18 log里面有写,也不支持,会报上面的错误


      2024-11-06
      0
    • Huanghui回复XR:

      bool 类型的input不支持!

      2024-11-06
      0
    • XR回复Huanghui:

      好的,谢谢我回去确认一下


      2024-11-06
      0
    • Huanghui回复XR:
      2024-11-06
      0
    • XR回复Huanghui:

      那请问可以支持哪个版本的reduce?


      2024-11-07
      0
  • Huanghui
    Lv.5

    收到,测试模型分享一下呢

    2024-11-05
    0
    1
    • XR回复Huanghui:

      附件不知道什么原因无法上传,但可以去onnx安装位置中的onnx/backend/test/data/node/test_reduce_max_bool_inputs中找到model.onnx

      2024-11-05
      0