This patch adds a workaround, which changes `scale` to one when tensor's
scale is zero, because currently zero scale is passed down from TF Lite.
Note that the latest NeuralNetworks.h (see
https://android.googlesource.com/platform/frameworks/ml/+/master/nn/runtime/include/NeuralNetworks.h)
requires `scale` to be greater than zero. Remove this workaround when
the scale value is correctly passed.
Signed-off-by: Sangmin Seo <sangmin7.seo@samsung.com>
case kTfLiteUInt8:
nn_type = ANEURALNETWORKS_TENSOR_QUANT8_ASYMM;
scale = tensor->params.scale;
+ // FIXME The next line is a workaround because currently zero scale is passed down from TF
+ // Lite. Note that the latest NeuralNetworks.h (see
+ // https://android.googlesource.com/platform/frameworks/ml/+/master/nn/runtime/include/NeuralNetworks.h)
+ // requires scale to be greater than zero. Remove this workaround when the scale
+ // value is correctly passed.
+ scale = (scale == 0.0f) ? 1.0f : scale;
zeroPoint = tensor->params.zero_point;
break;
case kTfLiteInt32: