OpenPPL / ppq

PPL Quantization Tool (PPQ) is a powerful offline neural network quantization tool.
Apache License 2.0
1.56k stars 236 forks source link

RuntimeError: Op Execution Error: /Slice(Type: Slice, Num of Input: 5, Num of Output: 1) #566

Open yehu3d opened 5 months ago

yehu3d commented 5 months ago

我在量化一个多输入模型:

dataset = CaliData(datapath, bs)
dataloader = data.DataLoader(dataset, batch_size=bs)
with ENABLE_CUDA_KERNEL():
    quantized = quantize_torch_model(
        model=model, calib_dataloader=dataloader,
        calib_steps=32, input_shape=None,inputs = next(iter(dataloader)),
        collate_fn=collate_fn, platform=PLATFORM, setting=QS,
        onnx_export_file='output.onnx', device=DEVICE, verbose=0)

报错如下:

[Warning] Unexpected input value of operation /Slice, recieving "None" at its input 0
Traceback (most recent call last):

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\executor\torch.py:536 in __forward
    outputs = operation_forward_func(operation, inputs, self._executing_context)

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\executor\op\torch\default.py:1404 in Slice_forward
    if pos_axes_slices: data = data[pos_axes_slices]

TypeError: 'NoneType' object is not subscriptable

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

Traceback (most recent call last):

  File D:\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File e:\int8\int8test.py:58
    quantized = quantize_torch_model(

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\core\defs.py:54 in _wrapper
    return func(*args, **kwargs)

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\api\interface.py:343 in quantize_torch_model
    return quantize_onnx_model(onnx_import_file=onnx_export_file,

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\core\defs.py:54 in _wrapper
    return func(*args, **kwargs)

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\api\interface.py:263 in quantize_onnx_model
    quantizer.quantize(

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\core\defs.py:54 in _wrapper
    return func(*args, **kwargs)

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\quantization\quantizer\base.py:52 in quantize
    executor.tracing_operation_meta(inputs=inputs)

  File D:\anaconda3\Lib\site-packages\torch\utils\_contextlib.py:115 in decorate_context
    return func(*args, **kwargs)

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\core\defs.py:54 in _wrapper
    return func(*args, **kwargs)

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\executor\torch.py:598 in tracing_operation_meta
    self.__forward(

  File D:\anaconda3\Lib\site-packages\ppq-0.6.6-py3.11.egg\ppq\executor\torch.py:563 in __forward
    raise RuntimeError(f'Op Execution Error: {str(operation)}') from _

RuntimeError: Op Execution Error: /Slice(Type: Slice, Num of Input: 5, Num of Output: 1)

不知道哪里错了,求大佬指点迷津,本人菜鸡初学者一枚