Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions paddle/fluid/operators/interpolate_v2_op.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1035,9 +1035,9 @@ static void Interpolate1DCUDAFwd(const framework::ExecutionContext& ctx,
: static_cast<float>(new_scale_w);
}

int in_cw = c * in_w;
int out_cw = c * out_w;
int pixelNum = n * out_cw;
int64_t in_cw = c * in_w;
int64_t out_cw = c * out_w;
auto pixelNum = n * out_cw;

platform::GpuLaunchConfig config =
platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), pixelNum);
Expand Down Expand Up @@ -1169,12 +1169,12 @@ static void Interpolate2DCUDAFwd(const framework::ExecutionContext& ctx,
: static_cast<float>(new_scale_w);
}

int in_hw = in_h * in_w;
int out_hw = out_h * out_w;
int in_chw = c * in_hw;
int out_chw = c * out_hw;
int64_t in_hw = in_h * in_w;
int64_t out_hw = out_h * out_w;
int64_t in_chw = c * in_hw;
int64_t out_chw = c * out_hw;

int pixelNum = n * out_chw;
auto pixelNum = n * out_chw;

platform::GpuLaunchConfig config =
platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), pixelNum);
Expand Down Expand Up @@ -1355,12 +1355,12 @@ static void Interpolate3DCUDAFwd(const framework::ExecutionContext& ctx,
: static_cast<float>(new_scale_w);
}

int in_dhw = in_d * in_h * in_w;
int out_dhw = out_d * out_h * out_w;
int in_cdhw = c * in_dhw;
int out_cdhw = c * out_dhw;
int64_t in_dhw = in_d * in_h * in_w;
int64_t out_dhw = out_d * out_h * out_w;
int64_t in_cdhw = c * in_dhw;
int64_t out_cdhw = c * out_dhw;

int pixelNum = n * out_cdhw;
auto pixelNum = n * out_cdhw;

platform::GpuLaunchConfig config =
platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), pixelNum);
Expand Down Expand Up @@ -1456,9 +1456,9 @@ static void Interpolate1DCUDABwd(const framework::ExecutionContext& ctx,
ratio_w = (align_corners) ? static_cast<float>(in_w - 1) / (out_w - 1)
: static_cast<float>(new_scale_w);
}
int in_cw = c * in_w;
int out_cw = c * out_w;
int pixelNum = n * out_cw;
int64_t in_cw = c * in_w;
int64_t out_cw = c * out_w;
auto pixelNum = n * out_cw;

platform::GpuLaunchConfig config =
platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), pixelNum);
Expand Down Expand Up @@ -1587,11 +1587,11 @@ static void Interpolate2DCUDABwd(const framework::ExecutionContext& ctx,
: static_cast<float>(new_scale_w);
}

int in_hw = in_h * in_w;
int out_hw = out_h * out_w;
int in_chw = c * in_hw;
int out_chw = c * out_hw;
int pixelNum = n * out_chw;
int64_t in_hw = in_h * in_w;
int64_t out_hw = out_h * out_w;
int64_t in_chw = c * in_hw;
int64_t out_chw = c * out_hw;
auto pixelNum = n * out_chw;

platform::GpuLaunchConfig config =
platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), pixelNum);
Expand Down Expand Up @@ -1773,12 +1773,12 @@ static void Interpolate3DCUDABwd(const framework::ExecutionContext& ctx,
: static_cast<float>(new_scale_w);
}

int in_dhw = in_d * in_h * in_w;
int out_dhw = out_d * out_h * out_w;
int in_cdhw = c * in_dhw;
int out_cdhw = c * out_dhw;
int64_t in_dhw = in_d * in_h * in_w;
int64_t out_dhw = out_d * out_h * out_w;
int64_t in_cdhw = c * in_dhw;
int64_t out_cdhw = c * out_dhw;

int pixelNum = n * out_cdhw;
auto pixelNum = n * out_cdhw;

platform::GpuLaunchConfig config =
platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), pixelNum);
Expand Down
20 changes: 11 additions & 9 deletions python/paddle/nn/functional/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,16 @@ def interpolate(x,
"align_corners option can only be set with the interpolating modes: linear | bilinear | bicubic | trilinear"
)

if resample == 'AREA' and len(x.shape) == 3:
return paddle.nn.functional.adaptive_avg_pool1d(x, size)

if resample == 'AREA' and len(x.shape) == 4:
return paddle.nn.functional.adaptive_avg_pool2d(x, size)
if resample == 'AREA' and len(x.shape) == 5:
return paddle.nn.functional.adaptive_avg_pool3d(x, size)
if resample == 'AREA':
if isinstance(size, list) or isinstance(size, tuple):
if len(size) == 0:
raise ValueError("output size can not be empty")
if len(x.shape) == 3:
return paddle.nn.functional.adaptive_avg_pool1d(x, size)
elif len(x.shape) == 4:
return paddle.nn.functional.adaptive_avg_pool2d(x, size)
elif len(x.shape) == 5:
return paddle.nn.functional.adaptive_avg_pool3d(x, size)

helper = LayerHelper('{}_interp_v2'.format(resample_type), **locals())
dtype = helper.input_dtype(input_param_name='x')
Expand Down Expand Up @@ -342,14 +345,13 @@ def _is_list_or_turple_(data):

out_shape = size
scale = scale_factor

if out_shape is not None and scale is not None:
raise ValueError("Only one of size or scale_factor should be defined.")
if out_shape is not None:

if isinstance(out_shape, Variable) and not in_dygraph_mode():
out_shape.stop_gradient = True
inputs['OutSize'] = out_shape

else:
if in_dygraph_mode():
if isinstance(out_shape, Variable):
Expand Down