onnxruntime
119daedf - Validate GatherBlockQuantized CUDA indices bounds (#31645)

Commit
6 days ago
Validate GatherBlockQuantized CUDA indices bounds (#31645) This pull request adds validation for index ranges in the CUDA implementation of the `GatherBlockQuantized` operator to prevent out-of-bounds memory access. It also introduces new unit tests to ensure the correctness of this validation, including cases with negative indices. The most important changes are grouped below: ### CUDA Index Range Validation * Added the `ValidateIndicesRangeForCuda` template function in `gather_block_quantized.cc` to check that all indices are within the valid range for the gather axis, supporting both CPU and CUDA memory. This prevents invalid memory access during CUDA kernel execution. * Integrated index validation into the `GatherBlockQuantized::ComputeInternal` method, ensuring validation is performed before computation proceeds. ### Unit Test Enhancements * Added the `Test_NegativeInvalidIndices_WithZeroPoints` test helper to cover cases with negative out-of-bounds indices. * Introduced new CUDA-specific tests (`InvalidIndices_Cuda` and `NegativeInvalidIndices_Cuda`) to verify that invalid indices (including negative values) are correctly detected and handled on CUDA devices.
Author
Parents
Loading