Skip to content

Commit 7ca66d1

Browse files
authored
Ensure int64 accumulation for bias-less 16x8 ops in TFLM kernels (#3598)
1 parent b6ee3dc commit 7ca66d1

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

tensorflow/lite/micro/kernels/cmsis_nn/conv.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ TfLiteStatus EvalInt16x8(TfLiteContext* context, TfLiteNode* node) {
392392
}
393393
const bool requires_int32_accum =
394394
(bias != nullptr && bias->type == kTfLiteInt32) ||
395-
(bias == nullptr && params.quantized_bias_type != kTfLiteInt64);
395+
(bias == nullptr && params.quantized_bias_type == kTfLiteInt32);
396396
if (requires_int32_accum) {
397397
return EvalQuantizedPerChannel<int16_t, int32_t, kTfLiteInt16>(
398398
context, node, params, data, input, filter, bias, output);

tensorflow/lite/micro/kernels/conv.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ TfLiteStatus ConvEval(TfLiteContext* context, TfLiteNode* node) {
8888
}
8989
const bool requires_int32_accum =
9090
(bias != nullptr && bias->type == kTfLiteInt32) ||
91-
(bias == nullptr && params.quantized_bias_type != kTfLiteInt64);
91+
(bias == nullptr && params.quantized_bias_type == kTfLiteInt32);
9292
if (requires_int32_accum) {
9393
reference_integer_ops::ConvPerChannel(
9494
ConvParamsQuantized(params, data),

tensorflow/lite/micro/kernels/fully_connected.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ TfLiteStatus FullyConnectedEval(TfLiteContext* context, TfLiteNode* node) {
240240
case kTfLiteInt8: {
241241
const bool requires_int32_accum =
242242
(bias != nullptr && bias->type == kTfLiteInt32) ||
243-
(bias == nullptr && params->quantized_bias_type != kTfLiteInt64);
243+
(bias == nullptr && params->quantized_bias_type == kTfLiteInt32);
244244
if (requires_int32_accum) {
245245
data.is_per_channel
246246
? tflite::reference_integer_ops::FullyConnectedPerChannel(

tensorflow/lite/micro/kernels/xtensa/conv.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
117117
// implementation, production use-cases should only have int64 bias.
118118
const bool requires_int32_accum =
119119
(bias != nullptr && bias->type == kTfLiteInt32) ||
120-
(bias == nullptr && params.quantized_bias_type != kTfLiteInt64);
120+
(bias == nullptr && params.quantized_bias_type == kTfLiteInt32);
121121
if (requires_int32_accum) {
122122
return ConvReferenceEvalInt16(context, node);
123123
} else {

tensorflow/lite/micro/kernels/xtensa/conv_int16_reference.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ TfLiteStatus ConvReferenceEvalInt16(TfLiteContext* context, TfLiteNode* node) {
6464
}
6565
const bool requires_int32_accum =
6666
(bias != nullptr && bias->type == kTfLiteInt32) ||
67-
(bias == nullptr && params.quantized_bias_type != kTfLiteInt64);
67+
(bias == nullptr && params.quantized_bias_type == kTfLiteInt32);
6868

6969
if (requires_int32_accum) {
7070
reference_integer_ops::ConvPerChannel(

0 commit comments

Comments
 (0)