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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions paddle/phi/kernels/cpu/interpolate_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ template <typename T>
static void LinearInterpolationGrad(const DenseTensor& output_grad,
DenseTensor* input_grad,
const float ratio_w,
const int in_w,
const int n,
const int c,
const int64_t in_w,
const int64_t n,
const int64_t c,
const int out_w,
const bool align_corners,
const int align_mode,
Expand Down Expand Up @@ -75,10 +75,10 @@ static void BilinearInterpolationGrad(const DenseTensor& output_grad,
DenseTensor* input_grad,
const float ratio_h,
const float ratio_w,
const int in_h,
const int in_w,
const int n,
const int c,
const int64_t in_h,
const int64_t in_w,
const int64_t n,
const int64_t c,
const int out_h,
const int out_w,
const bool align_corners,
Expand Down Expand Up @@ -142,8 +142,8 @@ static void NearestNeighborInterpolateGrad(const DenseTensor& output_grad,
DenseTensor* input_grad,
const float ratio_h,
const float ratio_w,
const int n,
const int c,
const int64_t n,
const int64_t c,
const int out_h,
const int out_w,
const bool align_corners,
Expand Down Expand Up @@ -179,10 +179,10 @@ static void BicubicInterpolationGrad(const DenseTensor& output_grad,
DenseTensor* input_grad,
const float ratio_h,
const float ratio_w,
const int in_h,
const int in_w,
const int n,
const int c,
const int64_t in_h,
const int64_t in_w,
const int64_t n,
const int64_t c,
const int out_h,
const int out_w,
const bool align_corners,
Expand All @@ -194,13 +194,13 @@ static void BicubicInterpolationGrad(const DenseTensor& output_grad,
for (int k = 0; k < out_h; k++) { // loop for images
MT y_n = align_corners ? ratio_h * static_cast<float>(k)
: ratio_h * (static_cast<float>(k) + 0.5f) - 0.5f;
int input_y = floorf(y_n);
int64_t input_y = floorf(y_n);
MT y_t = y_n - input_y;

for (int l = 0; l < out_w; l++) {
MT x_n = align_corners ? ratio_w * static_cast<float>(l)
: ratio_w * (static_cast<float>(l) + 0.5f) - 0.5f;
int input_x = floorf(x_n);
int64_t input_x = floorf(x_n);
MT x_t = x_n - input_x;

std::array<MT, 4> x_coeffs;
Expand All @@ -215,9 +215,9 @@ static void BicubicInterpolationGrad(const DenseTensor& output_grad,
for (int ii = 0; ii < 4; ii++) {
for (int jj = 0; jj < 4; jj++) {
int access_x = std::max(std::min(input_x - 1 + ii, in_w - 1),
static_cast<int>(0));
static_cast<int64_t>(0));
int access_y = std::max(std::min(input_y - 1 + jj, in_h - 1),
static_cast<int>(0));
static_cast<int64_t>(0));
if (data_layout == DataLayout::kNCHW) {
MT grad = static_cast<MT>(output_grad_t(i, j, k, l));
input_grad_t(i, j, access_y, access_x) +=
Expand All @@ -241,11 +241,11 @@ static void TrilinearInterpolationGrad(const DenseTensor& output_grad,
const float ratio_d,
const float ratio_h,
const float ratio_w,
const int in_d,
const int in_h,
const int in_w,
const int n,
const int c,
const int64_t in_d,
const int64_t in_h,
const int64_t in_w,
const int64_t n,
const int64_t c,
const int out_d,
const int out_h,
const int out_w,
Expand Down Expand Up @@ -348,8 +348,8 @@ static void NearestNeighbor3DInterpolateGrad(const DenseTensor& output_grad,
const float ratio_d,
const float ratio_h,
const float ratio_w,
const int n,
const int c,
const int64_t n,
const int64_t c,
const int out_d,
const int out_h,
const int out_w,
Expand Down Expand Up @@ -407,7 +407,7 @@ static void Interpolate1DCPUBwd(
int align_mode,
DenseTensor* input_grad) {
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
int64_t n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
funcs::ExtractNCDWH(input.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_w = -1.0;
Expand Down Expand Up @@ -508,7 +508,7 @@ static void Interpolate2DCPUBwd(
int align_mode,
DenseTensor* input_grad) {
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
int64_t n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
funcs::ExtractNCDWH(input.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_h = -1;
Expand Down Expand Up @@ -674,7 +674,7 @@ static void Interpolate3DCPUBwd(
int align_mode,
DenseTensor* input_grad) {
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
int64_t n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
funcs::ExtractNCDWH(input.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_d = -1;
Expand Down
6 changes: 3 additions & 3 deletions paddle/phi/kernels/cpu/interpolate_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ static void Interpolate1DCPUFwd(
int align_mode,
DenseTensor* output) {
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
int64_t n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
funcs::ExtractNCDWH(x.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_w = -1.;
Expand Down Expand Up @@ -662,7 +662,7 @@ static void Interpolate2DCPUFwd(
int align_mode,
DenseTensor* output) {
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
int64_t n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
funcs::ExtractNCDWH(x.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_h = -1;
Expand Down Expand Up @@ -833,7 +833,7 @@ static void Interpolate3DCPUFwd(
int align_mode,
DenseTensor* output) {
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
int64_t n = 0, c = 0, in_d = 0, in_h = 0, in_w = 0;
funcs::ExtractNCDWH(x.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_d = -1;
Expand Down
10 changes: 5 additions & 5 deletions paddle/phi/kernels/funcs/interpolate_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ HOSTDEVICE inline void get_cubic_upsample_coefficients(T coeffs[4], T t) {

inline void ExtractNCDWH(const DDim& dims,
const DataLayout& data_layout,
int* N,
int* C,
int* D,
int* H,
int* W) {
int64_t* N,
int64_t* C,
int64_t* D,
int64_t* H,
int64_t* W) {
*N = dims[0];

if (dims.size() == 3) {
Expand Down
6 changes: 3 additions & 3 deletions paddle/phi/kernels/gpu/interpolate_grad_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ static void Interpolate1DCUDABwd(
int align_mode,
DenseTensor* input_grad) {
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n, c, in_d, in_h, in_w;
int64_t n, c, in_d, in_h, in_w;
funcs::ExtractNCDWH(input.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_w = -1;
Expand Down Expand Up @@ -961,7 +961,7 @@ static void Interpolate2DCUDABwd(
int align_mode,
DenseTensor* input_grad) {
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n, c, in_d, in_h, in_w;
int64_t n, c, in_d, in_h, in_w;
funcs::ExtractNCDWH(input.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_h = -1;
Expand Down Expand Up @@ -1239,7 +1239,7 @@ static void Interpolate3DCUDABwd(
int align_mode,
DenseTensor* input_grad) {
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n, c, in_d, in_h, in_w;
int64_t n, c, in_d, in_h, in_w;
funcs::ExtractNCDWH(input.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_d = -1;
Expand Down
6 changes: 3 additions & 3 deletions paddle/phi/kernels/gpu/interpolate_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ static void Interpolate1DCUDAFwd(
auto* input_data = input.data<T>();

const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n, c, in_d, in_h, in_w;
int64_t n, c, in_d, in_h, in_w;
funcs::ExtractNCDWH(input.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_w = -1;
Expand Down Expand Up @@ -759,7 +759,7 @@ static void Interpolate2DCUDAFwd(
auto* input_data = input.data<T>();

const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n, c, in_d, in_h, in_w;
int64_t n, c, in_d, in_h, in_w;
funcs::ExtractNCDWH(input.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_w = -1;
Expand Down Expand Up @@ -1011,7 +1011,7 @@ static void Interpolate3DCUDAFwd(
auto* input_data = input.data<T>();

const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n, c, in_d, in_h, in_w;
int64_t n, c, in_d, in_h, in_w;
funcs::ExtractNCDWH(input.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_w = -1;
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/xpu/interpolate_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void InterpolateGradKernel(
return;
}
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n, c, in_d, in_h, in_w;
int64_t n, c, in_d, in_h, in_w;
funcs::ExtractNCDWH(x.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_h = -1;
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/xpu/interpolate_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void InterpolateKernel(
}
using XPUType = typename XPUTypeTrait<T>::Type;
const DataLayout data_layout = common::StringToDataLayout(data_layout_str);
int n, c, in_d, in_h, in_w;
int64_t n, c, in_d, in_h, in_w;
phi::funcs::ExtractNCDWH(x.dims(), data_layout, &n, &c, &in_d, &in_h, &in_w);

float scale_h = -1;
Expand Down
Loading