Skip to content

Commit

Permalink
Fix division by zero in TFLite padding.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 370777494
Change-Id: Ic1331e4a1603b9e4c8aa183012a6c8237410aa0f
  • Loading branch information
mihaimaruseac authored and geetachavan1 committed May 26, 2021
1 parent 711324e commit 3c40555
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tensorflow/lite/kernels/padding.h
Original file line number Diff line number Diff line change
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 3c40555

Please sign in to comment.