Skip to content

Commit

Permalink
[TOPI] Fix uint8 resize_bilinear issue. (apache#2490)
Browse files Browse the repository at this point in the history
Signed-off-by: Zhebin Jin <[email protected]>
  • Loading branch information
Rasterer authored and srkreddy1238 committed Jan 25, 2019
1 parent 6d6762f commit 4e57323
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions topi/include/topi/image/resize.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ inline Expr bilinear_sample_nchw(const Tensor& input, const Array<Expr>& indices
auto C = input(indices[0], indices[1], y1, x0);
auto D = input(indices[0], indices[1], y1, x1);

auto top = A + (B - A) * x_lerp;
auto bottom = C + (D - C) * x_lerp;

return (top + (bottom - top) * y_lerp);
return A * ( 1 - x_lerp) * ( 1 - y_lerp) +
B * x_lerp * (1 - y_lerp) +
C * (1 - x_lerp) * y_lerp +
D * x_lerp * y_lerp;
}

/*!
Expand Down Expand Up @@ -231,10 +231,10 @@ inline Tensor resize_bilinear_nhwc(const Tensor& input,
auto C = input(indices[0], y1, x0, indices[3]);
auto D = input(indices[0], y1, x1, indices[3]);

auto top = A + (B - A) * x_lerp;
auto bottom = C + (D - C) * x_lerp;

return (top + (bottom - top) * y_lerp);
return A * ( 1 - x_lerp) * ( 1 - y_lerp) +
B * x_lerp * (1 - y_lerp) +
C * (1 - x_lerp) * y_lerp +
D * x_lerp * y_lerp;
}, name, tag);
}

Expand Down

0 comments on commit 4e57323

Please sign in to comment.