From f3e57ec580bccd501dc7fd86584a2b37d91e68b3 Mon Sep 17 00:00:00 2001 From: Biruk Mammo Date: Fri, 29 May 2026 07:52:47 -0700 Subject: [PATCH] Miscellaneous cleanup. * Updates NUMA binding guard in allocator.cc to match the include guard. * Initializes vectors in flash_attention.cc. * Excludes SCALAR for HWY_RISCV in compression/types.h. PiperOrigin-RevId: 923412884 --- compression/types.h | 2 ++ gemma/flash_attention.cc | 3 ++- io/BUILD.bazel | 3 ++- util/allocator.cc | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compression/types.h b/compression/types.h index 20b33ce5..4de2a2d3 100644 --- a/compression/types.h +++ b/compression/types.h @@ -53,6 +53,8 @@ namespace gcpp { (HWY_SCALAR | HWY_SSE2 | HWY_SSSE3 | HWY_SSE4 | HWY_AVX10_2) #elif HWY_ARCH_WASM #define GEMMA_DISABLED_TARGETS HWY_SCALAR +#elif HWY_ARCH_RISCV +#define GEMMA_DISABLED_TARGETS HWY_SCALAR #endif // HWY_ARCH_* #endif // GEMMA_DISABLED_TARGETS diff --git a/gemma/flash_attention.cc b/gemma/flash_attention.cc index f9672857..9c4bd1b2 100644 --- a/gemma/flash_attention.cc +++ b/gemma/flash_attention.cc @@ -571,7 +571,8 @@ static HWY_INLINE void FlashAttentionTileStepAndApplySoftCap4( using VF4 = hn::Vec; static_assert(kNumQueries >= 1 && kNumQueries <= 4); VF4 new_max = hn::Set(df4, kNegInf); - VF max_0, max_1, max_2, max_3 = hn::Zero(df); + VF max_0 = hn::Zero(df), max_1 = hn::Zero(df), max_2 = hn::Zero(df), + max_3 = hn::Zero(df); max_0 = hn::Max(x_0_p0, x_0_p1); if constexpr (kNumQueries >= 2) { max_1 = hn::Max(x_1_p0, x_1_p1); diff --git a/io/BUILD.bazel b/io/BUILD.bazel index 444115ae..3d88ef90 100644 --- a/io/BUILD.bazel +++ b/io/BUILD.bazel @@ -29,7 +29,8 @@ FILE_DEPS = select({ # Placeholder for io deps, do not remove ], ":android": [], - # Placeholder for internal build rules, do not remove + # Placeholder 1 for internal build rules, do not remove + # Placeholder 2 for internal build rules, do not remove }) cc_library( diff --git a/util/allocator.cc b/util/allocator.cc index ecedba5d..9ff19641 100644 --- a/util/allocator.cc +++ b/util/allocator.cc @@ -236,7 +236,7 @@ AlignedPtr Allocator::AllocBytes(size_t bytes) const { // Binding, or large vector/cache line size: use platform-specific allocator. -#if HWY_OS_LINUX && !defined(__ANDROID_API__) +#if GEMMA_BIND && HWY_OS_LINUX && !defined(__ANDROID_API__) // `move_pages` is documented to require an anonymous/private mapping or // `MAP_SHARED`. A normal allocation might not suffice, so we use `mmap`. // `Init` verified that the page size is a multiple of `QuantumBytes()`.