Skip to content

Commit 53bcd7a

Browse files
Merge pull request #917 from plawanrath:fix/flash-attention-test-link-error
PiperOrigin-RevId: 922154211
2 parents 43843c6 + 1984298 commit 53bcd7a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,18 @@ set(GEMMA_ENABLE_TESTS OFF CACHE BOOL "Enable Gemma tests")
240240
if (GEMMA_ENABLE_TESTS)
241241

242242
enable_testing()
243+
find_package(GTest REQUIRED)
243244
include(GoogleTest)
244245

246+
# Tests use HWY_IS_TEST=1 with `hwy/foreach_target.h`, which expands the test
247+
# TU for every attainable SIMD target (including EMU128). libgemma's
248+
# foreach_target sources (flash_attention.cc, attention.cc, gemma.cc, vit.cc)
249+
# normally compile only for the baseline+best targets, so tests would fail to
250+
# link against per-target symbols like N_EMU128::FlashAttention. Build
251+
# libgemma for all attainable targets when tests are enabled, matching what
252+
# the tests reference.
253+
target_compile_definitions(libgemma PRIVATE HWY_IS_TEST=1)
254+
245255
set(GEMMA_TEST_FILES
246256
compression/compress_test.cc
247257
compression/distortion_test.cc

0 commit comments

Comments
 (0)