Guard CUDA LayerNorm/RMSNorm int32 offset range (#31650)
This pull request adds input validation checks to prevent integer
overflow issues during CUDA kernel indexing in the LayerNorm and RMSNorm
CUDA operators. The main goal is to ensure that the product of
`num_rows` and `norm_size` does not exceed `INT_MAX`, which could lead
to incorrect behavior or crashes.
Input validation for CUDA kernel indexing:
* Added a check in `LayerNorm::ComputeInternal` (in `layer_norm.cc`) to
return an error if `num_rows * norm_size` exceeds `INT_MAX`, preventing
integer overflow during CUDA kernel indexing.
* Added a similar check in `RMSNorm::ComputeInternal` (in `rms_norm.cc`)
to ensure the input size does not exceed CUDA kernel indexing limits.
Code maintenance:
* Included the `<limits>` header in both `layer_norm.cc` and
`rms_norm.cc` to support the new input validation logic.
[[1]](diffhunk://#diff-ebda3d3b7054f5d14c679ebe8e6520a2c84a5a558d8fdcc0798c08e7032345feR9)
[[2]](diffhunk://#diff-adebea99f15800767eb7b84d40be4873e81ca4df99ffe9dc7f849eabe0a3c563R9)
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>