Skip to content

Commit 3512a18

Browse files
jgibson2Copilot
andauthored
Update kernels/portable/cpu/op_grid_sampler_2d.cpp
Co-authored-by: Copilot <[email protected]>
1 parent c0a3db9 commit 3512a18

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernels/portable/cpu/op_grid_sampler_2d.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ void grid_sample_2d_nearest_kernel_impl_nchw(
217217
// For border/reflection padding, clip coordinates after rounding
218218
// Rounding can push coordinates out of bounds even after
219219
// grid_sampler_compute_source_index
220-
ix_nearest = clip_coordinates(ix_nearest, inp_W);
221-
iy_nearest = clip_coordinates(iy_nearest, inp_H);
220+
int64_t ix_clipped = clip_coordinates(ix_nearest, inp_W);
221+
int64_t iy_clipped = clip_coordinates(iy_nearest, inp_H);
222222
out_val = in_data
223-
[in_channel_offset + iy_nearest * in.strides()[2] +
224-
ix_nearest * in.strides()[3]];
223+
[in_channel_offset + iy_clipped * in.strides()[2] +
224+
ix_clipped * in.strides()[3]];
225225
}
226226

227227
// Write output in NCHW order

0 commit comments

Comments
 (0)