Skip to content

Commit

Permalink
Fix issue microsoft#10607, grid_sample CUDA kernel clamping is incorr…
Browse files Browse the repository at this point in the history
…ect for border padding mode with align = 1.
  • Loading branch information
mtavenrath committed Feb 21, 2024
1 parent 89d697a commit e88f1b2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions onnxruntime/contrib_ops/cuda/grid_sample_impl.cu
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ __global__ void _GridSampleKernel(
if (grid_x_imgSpace < x_min || grid_x_imgSpace > x_max ||
grid_y_imgSpace < y_min || grid_y_imgSpace > y_max) { // out of bound
if (padding_mode == 1) { // border
grid_x_imgSpace = max(0.0f, min(grid_x_imgSpace, W_in - 1.0f));
grid_y_imgSpace = max(0.0f, min(grid_y_imgSpace, H_in - 1.0f));
// Clamping must not be done here, see #10607
//grid_x_imgSpace = max(0.0f, min(grid_x_imgSpace, W_in - 1.0f));
//grid_y_imgSpace = max(0.0f, min(grid_y_imgSpace, H_in - 1.0f));
} else if (padding_mode == 2) { // reflection
grid_x_imgSpace = GsReflect(grid_x_imgSpace, x_min, x_max);
grid_y_imgSpace = GsReflect(grid_y_imgSpace, y_min, y_max);
Expand Down

0 comments on commit e88f1b2

Please sign in to comment.