Skip to content

Commit aa06d8f

Browse files
authored
[Big Tensor]Fix accuracy diff for paddle.nn.functional.adaptive_max_pool3d API (#74279)
1 parent f94bdcb commit aa06d8f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

paddle/phi/kernels/funcs/pooling.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,15 @@ class LPPoolGrad {
126126

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

135-
template <typename T = int>
134+
template <typename T = int64_t>
136135
HOSTDEVICE inline T AdaptEndIndex(T ph, T input_size, T output_size) {
137-
return static_cast<T>(
138-
ceil(static_cast<float>((ph + 1) * input_size) / output_size));
136+
return ((ph + 1) * input_size + output_size - 1) / output_size;
139137
}
140-
141138
/* used for fractional pool to calculate start and end index of each divided
142139
* grid
143140
*/

0 commit comments

Comments
 (0)