From 0cbea0ce2dece50c3b2befc86ff6e5d2e1f0ed27 Mon Sep 17 00:00:00 2001 From: Loser Cheems Date: Mon, 23 Jun 2025 13:51:57 +0800 Subject: [PATCH] Adds conditional softcap switch macro Introduces a new SOFTCAP_SWITCH macro that can be conditionally disabled via the FLASHATTENTION_DISABLE_SOFTCAP preprocessor flag. When the flag is defined, the macro forces the condition to false, effectively disabling softcap functionality. Otherwise, it defaults to the standard BOOL_SWITCH behavior. --- csrc/src/static_switch.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/csrc/src/static_switch.h b/csrc/src/static_switch.h index d912812..00322bd 100644 --- a/csrc/src/static_switch.h +++ b/csrc/src/static_switch.h @@ -46,6 +46,16 @@ #define EVENK_SWITCH BOOL_SWITCH #endif +#ifdef FLASHATTENTION_DISABLE_SOFTCAP + #define SOFTCAP_SWITCH(COND, CONST_NAME, ...) \ + [&] { \ + constexpr static bool CONST_NAME = false; \ + return __VA_ARGS__(); \ + }() +#else + #define SOFTCAP_SWITCH BOOL_SWITCH +#endif + #define FP16_SWITCH(COND, ...) \ [&] { \ if (COND) { \