// auto generated by generate_cpu_attn_dispatch.py
// clang-format off

#ifndef CPU_ATTN_DISPATCH_GENERATED_H
#define CPU_ATTN_DISPATCH_GENERATED_H

#include "cpu_attn_vec.hpp"
#include "cpu_attn_vec16.hpp"

#ifdef CPU_CAPABILITY_AMXBF16
  #include "cpu_attn_amx.hpp"
#endif

#ifdef __aarch64__
  #include "cpu_attn_neon.hpp"
#endif

#ifdef __s390x__
  #include "cpu_attn_vxe.hpp"
#endif

#ifdef __powerpc__
  #include "cpu_attn_vsx.hpp"
#endif


inline int64_t encode_cpu_attn_params(int64_t head_dim, cpu_attention::ISA isa,
                                      int64_t kv_cache_idx = 0) {
  return (head_dim << 16) | (kv_cache_idx << 8) | static_cast<int64_t>(isa);
}

// Dispatch macro using encoded parameters.
// KV_CACHE_IDX: Fp8KVCacheDataType enum value (kAuto=0, kFp8E4M3=1, kFp8E5M2=2).
// FP8 cases (kv_cache_idx != 0) are generated on x86 platforms with AVX2 or
// AVX-512: BF16Vec32 FP8 constructors have both AVX-512 and AVX2 implementations
// in cpu_types_x86.hpp. Non-x86 platforms (#else fallback) have fp8=False.
#if defined(CPU_CAPABILITY_AMXBF16)
#define CPU_ATTN_DISPATCH(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX, ...) \
  [&] { \
    int64_t encoded_params = encode_cpu_attn_params(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX); \
    switch (encoded_params) { \
      case 2097152LL: { /* head_dim=32, isa=AMX */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097153LL: { /* head_dim=32, isa=VEC */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097154LL: { /* head_dim=32, isa=VEC16 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194304LL: { /* head_dim=64, isa=AMX */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194305LL: { /* head_dim=64, isa=VEC */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194306LL: { /* head_dim=64, isa=VEC16 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291456LL: { /* head_dim=96, isa=AMX */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291457LL: { /* head_dim=96, isa=VEC */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291458LL: { /* head_dim=96, isa=VEC16 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388608LL: { /* head_dim=128, isa=AMX */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388609LL: { /* head_dim=128, isa=VEC */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388610LL: { /* head_dim=128, isa=VEC16 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485760LL: { /* head_dim=160, isa=AMX */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485761LL: { /* head_dim=160, isa=VEC */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485762LL: { /* head_dim=160, isa=VEC16 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582912LL: { /* head_dim=192, isa=AMX */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582913LL: { /* head_dim=192, isa=VEC */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582914LL: { /* head_dim=192, isa=VEC16 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680064LL: { /* head_dim=224, isa=AMX */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680065LL: { /* head_dim=224, isa=VEC */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680066LL: { /* head_dim=224, isa=VEC16 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777216LL: { /* head_dim=256, isa=AMX */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777217LL: { /* head_dim=256, isa=VEC */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777218LL: { /* head_dim=256, isa=VEC16 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554432LL: { /* head_dim=512, isa=AMX */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554433LL: { /* head_dim=512, isa=VEC */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554434LL: { /* head_dim=512, isa=VEC16 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242880LL: { /* head_dim=80, isa=AMX */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242881LL: { /* head_dim=80, isa=VEC */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242882LL: { /* head_dim=80, isa=VEC16 */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340032LL: { /* head_dim=112, isa=AMX */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340033LL: { /* head_dim=112, isa=VEC */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340034LL: { /* head_dim=112, isa=VEC16 */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097408LL: { /* head_dim=32, isa=AMX, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 2097409LL: { /* head_dim=32, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 4194560LL: { /* head_dim=64, isa=AMX, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 4194561LL: { /* head_dim=64, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 6291712LL: { /* head_dim=96, isa=AMX, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 6291713LL: { /* head_dim=96, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 8388864LL: { /* head_dim=128, isa=AMX, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 8388865LL: { /* head_dim=128, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 10486016LL: { /* head_dim=160, isa=AMX, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 10486017LL: { /* head_dim=160, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 12583168LL: { /* head_dim=192, isa=AMX, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 12583169LL: { /* head_dim=192, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 14680320LL: { /* head_dim=224, isa=AMX, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 14680321LL: { /* head_dim=224, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 16777472LL: { /* head_dim=256, isa=AMX, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 16777473LL: { /* head_dim=256, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 33554688LL: { /* head_dim=512, isa=AMX, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 33554689LL: { /* head_dim=512, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 2097664LL: { /* head_dim=32, isa=AMX, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 2097665LL: { /* head_dim=32, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 4194816LL: { /* head_dim=64, isa=AMX, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 4194817LL: { /* head_dim=64, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 6291968LL: { /* head_dim=96, isa=AMX, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 6291969LL: { /* head_dim=96, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 8389120LL: { /* head_dim=128, isa=AMX, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 8389121LL: { /* head_dim=128, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 10486272LL: { /* head_dim=160, isa=AMX, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 10486273LL: { /* head_dim=160, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 12583424LL: { /* head_dim=192, isa=AMX, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 12583425LL: { /* head_dim=192, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 14680576LL: { /* head_dim=224, isa=AMX, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 14680577LL: { /* head_dim=224, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 16777728LL: { /* head_dim=256, isa=AMX, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 16777729LL: { /* head_dim=256, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 33554944LL: { /* head_dim=512, isa=AMX, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::AMX, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 33554945LL: { /* head_dim=512, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      default: { \
        TORCH_CHECK(false, "Unsupported CPU attention configuration: head_dim=" + \
                    std::to_string(HEAD_DIM) + " isa=" + \
                    std::to_string(static_cast<int>(ISA_TYPE)) + \
                    " kv_cache_idx=" + std::to_string(KV_CACHE_IDX)); \
      } \
    } \
  }()

#elif defined(__aarch64__)
#define CPU_ATTN_DISPATCH(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX, ...) \
  [&] { \
    int64_t encoded_params = encode_cpu_attn_params(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX); \
    switch (encoded_params) { \
      case 2097155LL: { /* head_dim=32, isa=NEON */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::NEON, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097153LL: { /* head_dim=32, isa=VEC */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097154LL: { /* head_dim=32, isa=VEC16 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194307LL: { /* head_dim=64, isa=NEON */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::NEON, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194305LL: { /* head_dim=64, isa=VEC */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194306LL: { /* head_dim=64, isa=VEC16 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291459LL: { /* head_dim=96, isa=NEON */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::NEON, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291457LL: { /* head_dim=96, isa=VEC */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291458LL: { /* head_dim=96, isa=VEC16 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388611LL: { /* head_dim=128, isa=NEON */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::NEON, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388609LL: { /* head_dim=128, isa=VEC */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388610LL: { /* head_dim=128, isa=VEC16 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485763LL: { /* head_dim=160, isa=NEON */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::NEON, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485761LL: { /* head_dim=160, isa=VEC */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485762LL: { /* head_dim=160, isa=VEC16 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582915LL: { /* head_dim=192, isa=NEON */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::NEON, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582913LL: { /* head_dim=192, isa=VEC */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582914LL: { /* head_dim=192, isa=VEC16 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680067LL: { /* head_dim=224, isa=NEON */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::NEON, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680065LL: { /* head_dim=224, isa=VEC */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680066LL: { /* head_dim=224, isa=VEC16 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777219LL: { /* head_dim=256, isa=NEON */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::NEON, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777217LL: { /* head_dim=256, isa=VEC */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777218LL: { /* head_dim=256, isa=VEC16 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554435LL: { /* head_dim=512, isa=NEON */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::NEON, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554433LL: { /* head_dim=512, isa=VEC */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554434LL: { /* head_dim=512, isa=VEC16 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242883LL: { /* head_dim=80, isa=NEON */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242881LL: { /* head_dim=80, isa=VEC */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242882LL: { /* head_dim=80, isa=VEC16 */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340035LL: { /* head_dim=112, isa=NEON */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340033LL: { /* head_dim=112, isa=VEC */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340034LL: { /* head_dim=112, isa=VEC16 */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      default: { \
        TORCH_CHECK(false, "Unsupported CPU attention configuration: head_dim=" + \
                    std::to_string(HEAD_DIM) + " isa=" + \
                    std::to_string(static_cast<int>(ISA_TYPE)) + \
                    " kv_cache_idx=" + std::to_string(KV_CACHE_IDX)); \
      } \
    } \
  }()

#elif defined(__s390x__)
#define CPU_ATTN_DISPATCH(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX, ...) \
  [&] { \
    int64_t encoded_params = encode_cpu_attn_params(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX); \
    switch (encoded_params) { \
      case 2097156LL: { /* head_dim=32, isa=VXE */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VXE, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097153LL: { /* head_dim=32, isa=VEC */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097154LL: { /* head_dim=32, isa=VEC16 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194308LL: { /* head_dim=64, isa=VXE */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VXE, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194305LL: { /* head_dim=64, isa=VEC */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194306LL: { /* head_dim=64, isa=VEC16 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291460LL: { /* head_dim=96, isa=VXE */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VXE, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291457LL: { /* head_dim=96, isa=VEC */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291458LL: { /* head_dim=96, isa=VEC16 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388612LL: { /* head_dim=128, isa=VXE */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VXE, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388609LL: { /* head_dim=128, isa=VEC */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388610LL: { /* head_dim=128, isa=VEC16 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485764LL: { /* head_dim=160, isa=VXE */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VXE, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485761LL: { /* head_dim=160, isa=VEC */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485762LL: { /* head_dim=160, isa=VEC16 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582916LL: { /* head_dim=192, isa=VXE */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VXE, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582913LL: { /* head_dim=192, isa=VEC */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582914LL: { /* head_dim=192, isa=VEC16 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680068LL: { /* head_dim=224, isa=VXE */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VXE, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680065LL: { /* head_dim=224, isa=VEC */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680066LL: { /* head_dim=224, isa=VEC16 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777220LL: { /* head_dim=256, isa=VXE */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VXE, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777217LL: { /* head_dim=256, isa=VEC */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777218LL: { /* head_dim=256, isa=VEC16 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554436LL: { /* head_dim=512, isa=VXE */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VXE, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554433LL: { /* head_dim=512, isa=VEC */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554434LL: { /* head_dim=512, isa=VEC16 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242884LL: { /* head_dim=80, isa=VXE */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242881LL: { /* head_dim=80, isa=VEC */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242882LL: { /* head_dim=80, isa=VEC16 */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340036LL: { /* head_dim=112, isa=VXE */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340033LL: { /* head_dim=112, isa=VEC */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340034LL: { /* head_dim=112, isa=VEC16 */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      default: { \
        TORCH_CHECK(false, "Unsupported CPU attention configuration: head_dim=" + \
                    std::to_string(HEAD_DIM) + " isa=" + \
                    std::to_string(static_cast<int>(ISA_TYPE)) + \
                    " kv_cache_idx=" + std::to_string(KV_CACHE_IDX)); \
      } \
    } \
  }()

#elif defined(__powerpc__)
#define CPU_ATTN_DISPATCH(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX, ...) \
  [&] { \
    int64_t encoded_params = encode_cpu_attn_params(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX); \
    switch (encoded_params) { \
      case 2097157LL: { /* head_dim=32, isa=VSX */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VSX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097153LL: { /* head_dim=32, isa=VEC */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097154LL: { /* head_dim=32, isa=VEC16 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194309LL: { /* head_dim=64, isa=VSX */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VSX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194305LL: { /* head_dim=64, isa=VEC */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194306LL: { /* head_dim=64, isa=VEC16 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291461LL: { /* head_dim=96, isa=VSX */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VSX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291457LL: { /* head_dim=96, isa=VEC */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291458LL: { /* head_dim=96, isa=VEC16 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388613LL: { /* head_dim=128, isa=VSX */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VSX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388609LL: { /* head_dim=128, isa=VEC */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388610LL: { /* head_dim=128, isa=VEC16 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485765LL: { /* head_dim=160, isa=VSX */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VSX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485761LL: { /* head_dim=160, isa=VEC */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485762LL: { /* head_dim=160, isa=VEC16 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582917LL: { /* head_dim=192, isa=VSX */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VSX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582913LL: { /* head_dim=192, isa=VEC */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582914LL: { /* head_dim=192, isa=VEC16 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680069LL: { /* head_dim=224, isa=VSX */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VSX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680065LL: { /* head_dim=224, isa=VEC */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680066LL: { /* head_dim=224, isa=VEC16 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777221LL: { /* head_dim=256, isa=VSX */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VSX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777217LL: { /* head_dim=256, isa=VEC */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777218LL: { /* head_dim=256, isa=VEC16 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554437LL: { /* head_dim=512, isa=VSX */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VSX, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554433LL: { /* head_dim=512, isa=VEC */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554434LL: { /* head_dim=512, isa=VEC16 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242885LL: { /* head_dim=80, isa=VSX */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242881LL: { /* head_dim=80, isa=VEC */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242882LL: { /* head_dim=80, isa=VEC16 */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340037LL: { /* head_dim=112, isa=VSX */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340033LL: { /* head_dim=112, isa=VEC */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340034LL: { /* head_dim=112, isa=VEC16 */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      default: { \
        TORCH_CHECK(false, "Unsupported CPU attention configuration: head_dim=" + \
                    std::to_string(HEAD_DIM) + " isa=" + \
                    std::to_string(static_cast<int>(ISA_TYPE)) + \
                    " kv_cache_idx=" + std::to_string(KV_CACHE_IDX)); \
      } \
    } \
  }()

#elif defined(__AVX512F__)
#define CPU_ATTN_DISPATCH(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX, ...) \
  [&] { \
    int64_t encoded_params = encode_cpu_attn_params(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX); \
    switch (encoded_params) { \
      case 2097153LL: { /* head_dim=32, isa=VEC */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097154LL: { /* head_dim=32, isa=VEC16 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194305LL: { /* head_dim=64, isa=VEC */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194306LL: { /* head_dim=64, isa=VEC16 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291457LL: { /* head_dim=96, isa=VEC */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291458LL: { /* head_dim=96, isa=VEC16 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388609LL: { /* head_dim=128, isa=VEC */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388610LL: { /* head_dim=128, isa=VEC16 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485761LL: { /* head_dim=160, isa=VEC */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485762LL: { /* head_dim=160, isa=VEC16 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582913LL: { /* head_dim=192, isa=VEC */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582914LL: { /* head_dim=192, isa=VEC16 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680065LL: { /* head_dim=224, isa=VEC */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680066LL: { /* head_dim=224, isa=VEC16 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777217LL: { /* head_dim=256, isa=VEC */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777218LL: { /* head_dim=256, isa=VEC16 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554433LL: { /* head_dim=512, isa=VEC */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554434LL: { /* head_dim=512, isa=VEC16 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242881LL: { /* head_dim=80, isa=VEC */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242882LL: { /* head_dim=80, isa=VEC16 */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340033LL: { /* head_dim=112, isa=VEC */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340034LL: { /* head_dim=112, isa=VEC16 */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097409LL: { /* head_dim=32, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 4194561LL: { /* head_dim=64, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 6291713LL: { /* head_dim=96, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 8388865LL: { /* head_dim=128, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 10486017LL: { /* head_dim=160, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 12583169LL: { /* head_dim=192, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 14680321LL: { /* head_dim=224, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 16777473LL: { /* head_dim=256, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 33554689LL: { /* head_dim=512, isa=VEC, kv_cache=fp8_e4m3 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e4m3fn>; \
        return __VA_ARGS__(); \
      } \
      case 2097665LL: { /* head_dim=32, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 4194817LL: { /* head_dim=64, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 6291969LL: { /* head_dim=96, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 8389121LL: { /* head_dim=128, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 10486273LL: { /* head_dim=160, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 12583425LL: { /* head_dim=192, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 14680577LL: { /* head_dim=224, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 16777729LL: { /* head_dim=256, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      case 33554945LL: { /* head_dim=512, isa=VEC, kv_cache=fp8_e5m2 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, c10::Float8_e5m2>; \
        return __VA_ARGS__(); \
      } \
      default: { \
        TORCH_CHECK(false, "Unsupported CPU attention configuration: head_dim=" + \
                    std::to_string(HEAD_DIM) + " isa=" + \
                    std::to_string(static_cast<int>(ISA_TYPE)) + \
                    " kv_cache_idx=" + std::to_string(KV_CACHE_IDX)); \
      } \
    } \
  }()

#elif defined(__AVX2__)
#define CPU_ATTN_DISPATCH(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX, ...) \
  [&] { \
    int64_t encoded_params = encode_cpu_attn_params(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX); \
    switch (encoded_params) { \
      case 2097153LL: { /* head_dim=32, isa=VEC */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097154LL: { /* head_dim=32, isa=VEC16 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194305LL: { /* head_dim=64, isa=VEC */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194306LL: { /* head_dim=64, isa=VEC16 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291457LL: { /* head_dim=96, isa=VEC */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291458LL: { /* head_dim=96, isa=VEC16 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388609LL: { /* head_dim=128, isa=VEC */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388610LL: { /* head_dim=128, isa=VEC16 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485761LL: { /* head_dim=160, isa=VEC */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485762LL: { /* head_dim=160, isa=VEC16 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582913LL: { /* head_dim=192, isa=VEC */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582914LL: { /* head_dim=192, isa=VEC16 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680065LL: { /* head_dim=224, isa=VEC */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680066LL: { /* head_dim=224, isa=VEC16 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777217LL: { /* head_dim=256, isa=VEC */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777218LL: { /* head_dim=256, isa=VEC16 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554433LL: { /* head_dim=512, isa=VEC */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554434LL: { /* head_dim=512, isa=VEC16 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242881LL: { /* head_dim=80, isa=VEC */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242882LL: { /* head_dim=80, isa=VEC16 */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340033LL: { /* head_dim=112, isa=VEC */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340034LL: { /* head_dim=112, isa=VEC16 */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      default: { \
        TORCH_CHECK(false, "Unsupported CPU attention configuration: head_dim=" + \
                    std::to_string(HEAD_DIM) + " isa=" + \
                    std::to_string(static_cast<int>(ISA_TYPE)) + \
                    " kv_cache_idx=" + std::to_string(KV_CACHE_IDX)); \
      } \
    } \
  }()

#else
#define CPU_ATTN_DISPATCH(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX, ...) \
  [&] { \
    int64_t encoded_params = encode_cpu_attn_params(HEAD_DIM, ISA_TYPE, KV_CACHE_IDX); \
    switch (encoded_params) { \
      case 2097153LL: { /* head_dim=32, isa=VEC */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 2097154LL: { /* head_dim=32, isa=VEC16 */ \
        constexpr size_t head_dim = 32; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194305LL: { /* head_dim=64, isa=VEC */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 4194306LL: { /* head_dim=64, isa=VEC16 */ \
        constexpr size_t head_dim = 64; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291457LL: { /* head_dim=96, isa=VEC */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 6291458LL: { /* head_dim=96, isa=VEC16 */ \
        constexpr size_t head_dim = 96; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388609LL: { /* head_dim=128, isa=VEC */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 8388610LL: { /* head_dim=128, isa=VEC16 */ \
        constexpr size_t head_dim = 128; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485761LL: { /* head_dim=160, isa=VEC */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 10485762LL: { /* head_dim=160, isa=VEC16 */ \
        constexpr size_t head_dim = 160; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582913LL: { /* head_dim=192, isa=VEC */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 12582914LL: { /* head_dim=192, isa=VEC16 */ \
        constexpr size_t head_dim = 192; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680065LL: { /* head_dim=224, isa=VEC */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 14680066LL: { /* head_dim=224, isa=VEC16 */ \
        constexpr size_t head_dim = 224; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777217LL: { /* head_dim=256, isa=VEC */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 16777218LL: { /* head_dim=256, isa=VEC16 */ \
        constexpr size_t head_dim = 256; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554433LL: { /* head_dim=512, isa=VEC */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 33554434LL: { /* head_dim=512, isa=VEC16 */ \
        constexpr size_t head_dim = 512; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242881LL: { /* head_dim=80, isa=VEC */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 5242882LL: { /* head_dim=80, isa=VEC16 */ \
        constexpr size_t head_dim = 80; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340033LL: { /* head_dim=112, isa=VEC */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      case 7340034LL: { /* head_dim=112, isa=VEC16 */ \
        constexpr size_t head_dim = 112; \
        using attn_impl = cpu_attention::AttentionImpl<cpu_attention::ISA::VEC16, \
                                                       scalar_t, head_dim, scalar_t>; \
        return __VA_ARGS__(); \
      } \
      default: { \
        TORCH_CHECK(false, "Unsupported CPU attention configuration: head_dim=" + \
                    std::to_string(HEAD_DIM) + " isa=" + \
                    std::to_string(static_cast<int>(ISA_TYPE)) + \
                    " kv_cache_idx=" + std::to_string(KV_CACHE_IDX)); \
      } \
    } \
  }()

#endif  /* CPU_CAPABILITY_AMXBF16 / __aarch64__ / __s390x__ / __powerpc__ */

#endif  // CPU_ATTN_DISPATCH_GENERATED_H
