NVIDIA / TensorRT-Incubator

Experimental projects related to TensorRT
81 stars 12 forks source link

[compile_fixture] Scale must be a constant tensor in quantize / dequantize op. #102

Open markkraay opened 3 months ago

markkraay commented 3 months ago

Related to compile_fixture (#37). test_dequantize and test_quantize fail compiler.compile with the following: Example Code:

        data = [4, 8]
        input_tp = tp.Tensor(data, dtype=tp.int8)
        scale = torch.tensor(0.5, dtype=TORCH_DTYPES[dtype])
        scale_tp = tp.Tensor(scale, dtype=dtype)
        dequantized = compile_fixture(tp.dequantize, input_tp, scale_tp, dtype)

Error Msg:

E       tripy.common.exception.TripyException: 
E       
E       --> /tripy/tests/integration/conftest.py:36 in wrapper()
E             |
E          36 |             compiled_func = compiler.compile(*compile_args, **compile_kwargs)
E             | 
E       
E       Scale must be a constant tensor in dequantize op.

tripy/common/exception.py:195: TripyException
yizhuoz004 commented 3 months ago

@markkraay Please provide more information to debug this issue.

yizhuoz004 commented 3 months ago

The root cause is in tripy/tripy/backend/compiler_api.py:L515, compiler uses full to create dummy input values for intial compilation. The fixes could be:

  1. implement const fold optimization for Fill op when shape is constant.
  2. The compile_fixture should add an argument to specify which tensors are inputs, while others are Parameters.