Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix division by zero in TFLite padding.
PiperOrigin-RevId: 370777494
Change-Id: Ic1331e4a1603b9e4c8aa183012a6c8237410aa0f
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Apr 27, 2021
1 parent b0e85b5 commit 49847ae
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 49847ae

Please sign in to comment.