From 72108d8dbec02dfc5a4df6990c4078550450e01d Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Fri, 9 Nov 2018 12:13:19 +0800 Subject: [PATCH] fix win compile error: EigenTenor * float unsupport. test=develop --- paddle/fluid/operators/grid_sampler_op.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/grid_sampler_op.h b/paddle/fluid/operators/grid_sampler_op.h index 0d5874fc0c..4e91a3dcd2 100644 --- a/paddle/fluid/operators/grid_sampler_op.h +++ b/paddle/fluid/operators/grid_sampler_op.h @@ -63,12 +63,19 @@ static void CalcGridLocations(const platform::CPUDeviceContext& ctx, Tensor ones; ones.mutable_data({n, h, w}, ctx.GetPlace()); auto ones_t = EigenTensor::From(ones).setConstant(1.0); + Tensor half_xmax, half_ymax; + half_xmax.mutable_data({n, h, w}, ctx.GetPlace()); + auto half_xmax_t = + EigenTensor::From(half_xmax).setConstant(0.5 * x_max); + half_ymax.mutable_data({n, h, w}, ctx.GetPlace()); + auto half_ymax_t = + EigenTensor::From(half_ymax).setConstant(0.5 * y_max); // scale grid to [0, h-1/w-1] auto grid_x_t = EigenTensor::From(grid_x); auto grid_y_t = EigenTensor::From(grid_y); - grid_x_t.device(place) = 0.5 * ((grid_x_t + ones_t) * x_max); - grid_y_t.device(place) = 0.5 * ((grid_y_t + ones_t) * y_max); + grid_x_t.device(place) = (grid_x_t + ones_t) * half_xmax_t; + grid_y_t.device(place) = (grid_y_t + ones_t) * half_ymax_t; // calculate coords of 4 corner points x_w->mutable_data({n, h, w}, ctx.GetPlace()); -- GitLab