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 <zhebin.jzb@alibaba-inc.com>
  • Loading branch information
Rasterer authored and Wei Chen committed Feb 20, 2019
1 parent 5521a15 commit babe9b8
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 babe9b8

Please sign in to comment.