Skip to content

Commit

Permalink
Merge pull request #49709 from geetachavan1/cherrypicks_FR9R6
Browse files Browse the repository at this point in the history
Fix division by zero in TFLite padding.
  • Loading branch information
mihaimaruseac committed May 26, 2021
2 parents 711324e + 3c40555 commit 161f244
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tensorflow/lite/kernels/padding.h
Expand Up @@ -44,6 +44,11 @@ inline int ComputePaddingWithOffset(int stride, int dilation_rate, int in_size,
inline int ComputeOutSize(TfLitePadding padding, int image_size,
int filter_size, int stride, int dilation_rate = 1) {
int effective_filter_size = (filter_size - 1) * dilation_rate + 1;

// TODO(b/186448822): This uses 0 since the function has no other way to
// report error case
if (stride == 0) return 0;

switch (padding) {
case kTfLitePaddingSame:
return (image_size + stride - 1) / stride;
Expand Down

0 comments on commit 161f244

Please sign in to comment.