char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
192067b72
char/aliceai-t5-moe
1#ifndef HTP_GET_ROWS_OPS_H 2#define HTP_GET_ROWS_OPS_H 3 4#include "hex-fastdiv.h" 5 6struct htp_get_rows_kernel_params { 7int32_t n_threads ; 8int32_t use_dma ; 9int32_t chunks_per_row ; 10int32_t chunk_size ; 11int32_t total_tasks ; 12int32_t tasks_per_thread ; 13int32_t vtcm_size ; 14 15// Fastdiv helpers 16struct fastdiv_values div_ne10 ; 17struct fastdiv_values div_ne10_ne11 ; 18struct fastdiv_values div_chunks_per_row ; 19struct fastdiv_values div_ne02 ; 20struct fastdiv_values div_ne03 ; 21}; 22 23struct htp_get_rows_vtcm_layout { 24size_t total_bytes ; 25size_t off_src0 ; 26size_t off_dst ; 27 28size_t src0_bytes_per_thread ; 29size_t dst_bytes_per_thread ; 30 31size_t src0_spad_half_size ; 32size_t dst_spad_half_size ; 33}; 34 35static inline void htp_get_rows_vtcm_layout_build ( 36struct htp_get_rows_vtcm_layout * vtcm_layout , 37int type , 38uint32_t ne00 , 39uint32_t n_threads ) { 40 41uint32_t src0_row_size = 0 ; 42switch (type ) { 43case 0 :// HTP_TYPE_F32 44src0_row_size = ne00 * 4 ; 45break ; 46case 1 :// HTP_TYPE_F16 47src0_row_size = ne00 * 2 ; 48break ; 49case 8 :// HTP_TYPE_Q8_0 50src0_row_size = (ne00 /32 )* 34 ; 51break ; 52default : 53src0_row_size = 0 ; 54break ; 55 } 56 57size_t src0_row_size_aligned = (src0_row_size + 255 )& ~255 ; 58size_t dst_row_size_aligned = (ne00 * sizeof (float )+ 255 )& ~255 ; 59 60vtcm_layout -> src0_spad_half_size = src0_row_size_aligned ; 61vtcm_layout -> dst_spad_half_size = dst_row_size_aligned ; 62 63vtcm_layout -> src0_bytes_per_thread = src0_row_size_aligned * 2 ; 64vtcm_layout -> dst_bytes_per_thread = dst_row_size_aligned * 2 ; 65 66vtcm_layout -> off_src0 = 0 ; 67vtcm_layout -> off_dst = vtcm_layout -> off_src0 + vtcm_layout -> src0_bytes_per_thread * n_threads ; 68vtcm_layout -> total_bytes = vtcm_layout -> off_dst + vtcm_layout -> dst_bytes_per_thread * n_threads ; 69} 70 71#if defined(__cplusplus ) 72static_assert (sizeof (struct htp_get_rows_kernel_params ) <=128 ,"htp_get_rows_kernel_params is too large for kernel_params blob" ); 73#else 74_Static_assert (sizeof (struct htp_get_rows_kernel_params ) <=128 ,"htp_get_rows_kernel_params is too large for kernel_params blob" ); 75#endif 76 77#endif // HTP_GET_ROWS_OPS_H