Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dipoorlet 支持动态输入吗 #26

Open
kyrie2to11 opened this issue Nov 7, 2023 · 1 comment
Open

dipoorlet 支持动态输入吗 #26

kyrie2to11 opened this issue Nov 7, 2023 · 1 comment

Comments

@kyrie2to11
Copy link

kyrie2to11 commented Nov 7, 2023

在试用dipoorlet PTQ量化 torch 导出的onnx模型时报错: ValueError: cannot reshape array of size 172800 into shape (0,0,3,180,320)。

  1. torch.onnx.export() 导出时指定了dynamic_axes, 具体如下:
torch.onnx.export(
        model, # torch model
        dummy_input, # random dummy input
        onnx_path, # save path of onnx format model
        export_params=True, # export all params
        verbose=True, # enable debug message
        training=torch.onnx.TrainingMode.EVAL, # export the model in inference mode
        input_names=input_names, # names to assign to input nodes of computation graph
        output_names=output_names, # names to assign to output nodes of computation graph
        opset_version=16, # version of opset
        # dynamic axes setting for dynamic input/output shapes
        dynamic_axes={
            "LR_bins":{0: "batch_size", 1:"temporal_dim"},
            "HR":{0: "batch_size", 1:"temporal_dim"}
        }
  1. 使用dipoorlet量化时具体报错如下:
root@autodl-container-032d11993c-d711a821:~/autodl-tmp/Dipoorlet_Examples# sh verification_trial.sh
[2023-11-07 14:59:14 dipoorlet](__main__.py 118): INFO Do tensor calibration...
Minmax update: 0it [00:00, ?it/s]
Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/root/miniconda3/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/root/autodl-tmp/Dipoorlet/dipoorlet/__main__.py", line 119, in <module>
    act_clip_val, weight_clip_val = tensor_calibration(onnx_graph, args)
  File "/root/autodl-tmp/Dipoorlet/dipoorlet/tensor_cali/tensor_cali_base.py", line 6, in tensor_calibration
    act_clip_val = tensor_cali_dispatcher(args.act_quant, onnx_graph, args)
  File "/root/autodl-tmp/Dipoorlet/dipoorlet/utils.py", line 297, in wrapper
    return dispatch(args[0])(*(args[1:]), **kw)
  File "/root/autodl-tmp/Dipoorlet/dipoorlet/tensor_cali/basic_algorithm.py", line 18, in find_clip_val_minmax
    stats_min_max = forward_get_minmax(onnx_graph, args)
  File "/root/autodl-tmp/Dipoorlet/dipoorlet/forward_net.py", line 215, in forward_get_minmax
    ort_inputs[name] = data[name][:].reshape(onnx_graph.get_tensor_shape(name))
ValueError: cannot reshape array of size 172800 into shape (0,0,3,180,320)
@gushiqiao
Copy link
Contributor

您好,现在还不支持动态输入shape,后续会改进,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants