tvm
tvm copied to clipboard
[BUG] Quantized convolution leagalization doesn't handle int16 dtypes for `arm_cpu` target
Expected behaviour:
When an arm_cpu target is used, the model should compile successfully without an error.
Actual error:
When compiled on an arm_cpu target, the models mentioned below result in the following error:
File "/workspaces/tvm/src/tvm/python/tvm/relay/qnn/op/legalizations.py", line 505, in _qnn_conv2d_legalize_arm_cpu
return helper_change_dtypes_to_be_same(attrs, inputs, types, relay.qnn.op.conv2d)
File "/workspaces/tvm/src/tvm/python/tvm/relay/qnn/op/legalizations.py", line 460, in helper_change_dtypes_to_be_same
assert (
AssertionError: Qnn Conv2D/Dense only accepts uint8 or int8 inputs
And the following warning is also generated during compilation:
data types int64 and int32 do not match in BroadcastRel
Environment:
Tested with TVM at https://github.com/apache/tvm/commit/6a3fadc0654ecf9557ffe08d24677684c96e80b0. The issue was found as a result of the changes in https://github.com/apache/tvm/pull/16513, however it can be reproduced without as described below.
How to reproduce:
Run either of the following tests:
pytest tests/python/frontend/tflite/test_forward.py -k test_forward_mobilenet_int16pytest tests/python/frontend/tflite/test_forward.py -k test_forward_ds_cnn_int16with anarm_cputarget. Note: Reminder to remove any skip condition that exists in the test currently.
Likely legalization of the quantized operator needs to be prevented when the data type is not unit8/int8 in https://github.com/apache/tvm/blob/8a2ffee38e6020083c857a3aaaecae29d982c5c7/python/tvm/relay/qnn/op/legalizations.py#L489