ggml-cuda: fix regex for arch list (#18371)

* ggml-cuda: fix regex for arch list

* make regex exact
This commit is contained in:
Aman Gupta 2025-12-26 01:35:14 +08:00 committed by GitHub
parent 83b3b1c271
commit 85c40c9b02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -44,8 +44,13 @@ if (CUDAToolkit_FOUND)
# Replace any 12x-real architectures with 12x{a}-real. FP4 ptx instructions are not available in just 12x
if (GGML_NATIVE)
set(PROCESSED_ARCHITECTURES "")
foreach(ARCH ${CMAKE_CUDA_ARCHITECTURES_NATIVE})
if(ARCH MATCHES "^12[0-9]$")
if (CMAKE_CUDA_ARCHITECTURES_NATIVE)
set(ARCH_LIST ${CMAKE_CUDA_ARCHITECTURES_NATIVE})
else()
set(ARCH_LIST ${CMAKE_CUDA_ARCHITECTURES})
endif()
foreach(ARCH ${ARCH_LIST})
if (ARCH MATCHES "^12[0-9](-real|-virtual)?$")
string(REGEX REPLACE "^(12[0-9]).*$" "\\1" BASE_ARCH ${ARCH})
message(STATUS "Replacing ${ARCH} with ${BASE_ARCH}a-real")
list(APPEND PROCESSED_ARCHITECTURES "${BASE_ARCH}a-real")