Skip to content

Commit 0f030ff

Browse files
Optimize the calculation of Number of parallel imgs in cpu
1 parent 969c99f commit 0f030ff

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

torchvision/csrc/ops/cpu/deform_conv2d_kernel.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,13 @@ void deformable_im2col(
244244
}
245245

246246
int get_greatest_divisor_below_bound(int n, int bound) {
247-
for (int k = bound; k > 1; --k) {
248-
if (n % k == 0) {
249-
return k;
247+
int limit = std::min(n/2, bound);
248+
for (int k = limit; k > 1; --k) {
249+
if (n % k == 0) {
250+
return k;
251+
}
250252
}
251-
}
252-
return 1;
253+
return 1;
253254
}
254255

255256
template <typename scalar_t>

0 commit comments

Comments
 (0)