From 4e57323552295dbd48cd5dc95875c592556092b4 Mon Sep 17 00:00:00 2001 From: Zhebin Jin Date: Fri, 25 Jan 2019 11:35:10 +0800 Subject: [PATCH] [TOPI] Fix uint8 resize_bilinear issue. (#2490) Signed-off-by: Zhebin Jin --- topi/include/topi/image/resize.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/topi/include/topi/image/resize.h b/topi/include/topi/image/resize.h index c6d2eb6015f3..ae1b9ff26425 100644 --- a/topi/include/topi/image/resize.h +++ b/topi/include/topi/image/resize.h @@ -54,10 +54,10 @@ inline Expr bilinear_sample_nchw(const Tensor& input, const Array& 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; } /*! @@ -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); }