Skip to content
3 changes: 2 additions & 1 deletion torchvision/csrc/ops/cpu/deform_conv2d_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ void deformable_im2col(
}

int get_greatest_divisor_below_bound(int n, int bound) {
for (int k = bound; k > 1; --k) {
int limit = std::min(n / 2, bound);
for (int k = limit; k > 1; --k) {
if (n % k == 0) {
return k;
}
Expand Down
3 changes: 2 additions & 1 deletion torchvision/csrc/ops/cuda/deform_conv2d_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ void deformable_im2col(
}

int get_greatest_divisor_below_bound(int n, int bound) {
for (int k = bound; k > 1; --k) {
int limit = std::min(n / 2, bound);
for (int k = limit; k > 1; --k) {
if (n % k == 0) {
return k;
}
Expand Down