Skip to content

Commit 170160a

Browse files
authored
Raise kernel launch errors instead of just print error message in cuda ops (#7080)
Co-authored-by: Yuxin Wu <[email protected]>
1 parent f84af6d commit 170160a

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

torchvision/csrc/ops/cuda/deform_conv2d_kernel.cu

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,7 @@ void deformable_im2col(
300300
data_col.data_ptr<scalar_t>());
301301
}));
302302
}
303-
304-
cudaError_t err = cudaGetLastError();
305-
if (err != cudaSuccess) {
306-
printf("error in deformable_im2col: %s\n", cudaGetErrorString(err));
307-
}
303+
C10_CUDA_KERNEL_LAUNCH_CHECK();
308304
}
309305

310306
int get_greatest_divisor_below_bound(int n, int bound) {
@@ -483,11 +479,7 @@ void compute_grad_input(
483479
grad_im.data_ptr<scalar_t>());
484480
}));
485481
}
486-
487-
cudaError_t err = cudaGetLastError();
488-
if (err != cudaSuccess) {
489-
printf("error in compute_grad_input: %s\n", cudaGetErrorString(err));
490-
}
482+
C10_CUDA_KERNEL_LAUNCH_CHECK();
491483
}
492484

493485
template <typename scalar_t, typename index_t>
@@ -736,12 +728,7 @@ void compute_grad_offset_and_mask(
736728
grad_mask.data_ptr<scalar_t>());
737729
}));
738730
}
739-
740-
cudaError_t err = cudaGetLastError();
741-
if (err != cudaSuccess) {
742-
printf(
743-
"error in compute_grad_offset_and_mask: %s\n", cudaGetErrorString(err));
744-
}
731+
C10_CUDA_KERNEL_LAUNCH_CHECK();
745732
}
746733

747734
std::tuple<at::Tensor, at::Tensor, at::Tensor> backward_gradient_inputs(

0 commit comments

Comments
 (0)