Fix kernel_util: all we need to do is input_product_scale & bias_scale are very similar.
previous logic can fail if both input_product_scale & bias_scale are already very small numbers. PiperOrigin-RevId: 306210519 Change-Id: Iad5f31d31f4e75dc0f569803c174bc265f36d699
This commit is contained in:
parent
f453f33156
commit
dc8475e8c9
@ -124,9 +124,11 @@ TfLiteStatus GetQuantizedConvolutionMultipler(TfLiteContext* context,
|
|||||||
// pipeline.
|
// pipeline.
|
||||||
if (bias) {
|
if (bias) {
|
||||||
const double bias_scale = static_cast<double>(bias->params.scale);
|
const double bias_scale = static_cast<double>(bias->params.scale);
|
||||||
TF_LITE_ENSURE(context,
|
// Here we're making sure the input_product_scale & bias_scale the same.
|
||||||
std::abs(input_product_scale - bias_scale) <=
|
// Normally this should be guaranteed by the training pipeline, we are
|
||||||
1e-6 * std::min(input_product_scale, bias_scale));
|
// setting the threshold to be 2e-6 to allow some numeric stability
|
||||||
|
// difference.
|
||||||
|
TF_LITE_ENSURE(context, std::abs(input_product_scale - bias_scale) <= 2e-6);
|
||||||
}
|
}
|
||||||
return GetQuantizedConvolutionMultipler(context, input, filter, output,
|
return GetQuantizedConvolutionMultipler(context, input, filter, output,
|
||||||
multiplier);
|
multiplier);
|
||||||
|
Loading…
Reference in New Issue
Block a user