Skip to content
Merged
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
11 changes: 4 additions & 7 deletions paddle/phi/kernels/funcs/pooling.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,15 @@ class LPPoolGrad {

/* used for adaptive pool to calculate start and end index of each divided grid
*/
template <typename T = int>
template <typename T = int64_t>
HOSTDEVICE inline T AdaptStartIndex(T ph, T input_size, T output_size) {
return static_cast<T>(
floor(static_cast<float>(ph * input_size) / output_size));
return (ph * input_size) / output_size;
}

template <typename T = int>
template <typename T = int64_t>
HOSTDEVICE inline T AdaptEndIndex(T ph, T input_size, T output_size) {
return static_cast<T>(
ceil(static_cast<float>((ph + 1) * input_size) / output_size));
return ((ph + 1) * input_size + output_size - 1) / output_size;
}

/* used for fractional pool to calculate start and end index of each divided
* grid
*/
Expand Down