Prevent division by 0

PiperOrigin-RevId: 370966645
Change-Id: I831bfd96c7eb77b02d7ebb744335f59f6e5728cb
This commit is contained in:
Mihai Maruseac
2021-04-28 12:57:00 -07:00
committed by Geeta Chavan
parent 0e8f43f76f
commit aed365181e

View File

@@ -68,6 +68,10 @@ TfLiteStatus EvalSimple(TfLiteContext* context, TfLiteNode* node,
const TfLiteTensor* lookup, const TfLiteTensor* value,
TfLiteTensor* output) {
const int row_size = SizeOfDimension(value, 0);
if (row_size == 0) {
// Propagate empty tensor if input is empty
return kTfLiteOk;
}
const int row_bytes = value->bytes / row_size;
char* output_raw = GetTensorData<char>(output);