Repository navigation
fix(kernels): fix 32-bit signed integer overflow in Dilation GPU kernels - #126937
copybara-service[bot] merged 1 commit into
Conversation
|
/gemini review |
|
Pushed cuda13 root cause: heuristic fix: switch forward + both backprop launches to the occupancy-aware overload: windows: still unrelated TFLite |
Use 64-bit launch configuration with occupancy-aware GetGpuLaunchConfig64 to prevent integer overflow on large tensors in 2D and 3D dilation kernels, while staying within device resource limits.
e127988 to
3b9e909
Compare
dmiltr3
left a comment
There was a problem hiding this comment.
Thank you for the fix! The changes to prevent 32-bit signed integer overflows in the 2D and 3D dilation kernels look correct, and everything passes the internal test suite cleanly.
Approving!
Why
In
tensorflow/core/kernels/dilation_ops_gpu.cu.cc,DilationKernel,DilationBackpropInputKernel, andDilationBackpropFilterKerneltookconst int32_t nthreadsand usedGPU_1D_KERNEL_LOOP(out_idx, nthreads), which expands tofor (int out_idx : GpuGridRangeX(nthreads)).In addition, the launcher functors calculated the total element count with signed 32-bit arithmetic and passed it to
GetGpuLaunchConfig(int, ...). Whenbatch * output_rows * output_cols * depth > INT32_MAX, that overflows, tripsCHECK_GE(work_element_count, 0), or launches with a truncated thread count.Scope
tensorflow/core/kernels/dilation_ops_gpu.cu.cc:nthreads, tensor dims, and loop indices toint64_t.GPU_1D_KERNEL_LOOPwithfor (int64_t out_idx : GpuGridRangeX(nthreads)).total_counttoint64_t.SetZeroinit launches) fromGetGpuLaunchConfigtoGetGpuLaunchConfig64, matchinggather_nd_op_gpu.cu.cc.Blast Radius
GPU Dilations2D forward/backprop only. CPU path untouched.
Verification
absl::StatusOr<GpuLaunchConfig64>+CHECK_OK, thenconfig->virtual_thread_countinto kernels.SetZeroalready takesint64_t counton current master.