Merge pull request #49776 from geetachavan1/cherrypicks_H6RZ3

Prevent division by 0
This commit is contained in:
Mihai Maruseac 2021-05-30 15:23:25 -07:00 committed by GitHub
commit 371a2c5d71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,6 +71,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);