char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
6d9c82ea2
char/aliceai-t5-moe
1#ifndef HTP_ROPE_OPS_H 2#define HTP_ROPE_OPS_H 3 4#include "hex-common.h" 5#include "hex-fastdiv.h" 6 7#define HTP_ROPE_SPAD_BLOCK 8 8#define HTP_ROPE_SPAD_NSLOTS 4 9#define HTP_ROPE_SPAD_NROWS (HTP_ROPE_SPAD_BLOCK * HTP_ROPE_SPAD_NSLOTS) 10 11struct htp_rope_kernel_params { 12uint32_t n_threads ; 13uint32_t src0_nrows ; 14uint32_t src0_nrows_per_thread ; 15uint32_t vtcm_size ; 16uint32_t spad_per_thread ; 17uint32_t theta_cache_offset ; 18uint32_t src0_row_size_aligned ; 19 20struct fastdiv_values div_ne2_ne1 ; 21struct fastdiv_values div_ne1 ; 22}; 23 24#if defined(__cplusplus ) 25static_assert (sizeof (struct htp_rope_kernel_params ) <=128 ,"htp_rope_kernel_params is too large for kernel_params blob" ); 26#else 27_Static_assert (sizeof (struct htp_rope_kernel_params ) <=128 ,"htp_rope_kernel_params is too large for kernel_params blob" ); 28#endif 29 30struct htp_rope_vtcm_layout { 31size_t total_bytes ; 32size_t bytes_per_thread ; 33size_t theta_cache_size_aligned ; 34size_t src0_row_size_aligned ; 35}; 36 37static inline void htp_rope_vtcm_layout_build ( 38struct htp_rope_vtcm_layout * layout , 39uint32_t ne00 , 40uint32_t n_threads 41) { 42const size_t src0_row_size = ne00 * sizeof (float ); 43const size_t src0_row_size_aligned = hex_round_up ((uint32_t )src0_row_size ,128 ); 44const size_t theta_cache_size_aligned = hex_round_up ((uint32_t )src0_row_size ,256 ); 45 46layout -> src0_row_size_aligned = src0_row_size_aligned ; 47layout -> theta_cache_size_aligned = theta_cache_size_aligned ; 48layout -> bytes_per_thread = theta_cache_size_aligned + HTP_ROPE_SPAD_NROWS * src0_row_size_aligned ; 49layout -> total_bytes = layout -> bytes_per_thread * n_threads ; 50} 51 52static inline uint8_t * rope_spad_slot (uint8_t * base ,uint32_t slot ,size_t row_size_aligned ) { 53return base + (slot * HTP_ROPE_SPAD_BLOCK )* row_size_aligned ; 54} 55 56#endif // HTP_ROPE_OPS_H