Skip to content

Commit 969c99f

Browse files
Optimize divisor search limit in get_greatest_divisor_below_bound
1 parent 58eb039 commit 969c99f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

torchvision/csrc/ops/cuda/deform_conv2d_kernel.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ void deformable_im2col(
305305
}
306306

307307
int get_greatest_divisor_below_bound(int n, int bound) {
308-
for (int k = bound; k > 1; --k) {
308+
int limit = std::min(n/2, bound);
309+
for (int k = limit; k > 1; --k) {
309310
if (n % k == 0) {
310311
return k;
311312
}

0 commit comments

Comments
 (0)