char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
7cadbfce1
char/aliceai-t5-moe
1#ifndef HEX_DUMP_H 2#define HEX_DUMP_H 3 4#include <HAP_farf.h> 5 6static inline void hex_dump_int8_line (char * pref ,const int8_t * x ,int n ) { 7char str [1024 ],* p = str ,* p_end = str + sizeof (str ); 8p += snprintf (p ,p_end - p ,"%s: " ,pref ); 9for (int i = 0 ;i < n && p < p_end ;i ++ ) { 10p += snprintf (p ,p_end - p ,"%d, " ,x [i ]); 11 } 12FARF (HIGH ,"%s\n" ,str ); 13} 14 15static inline void hex_dump_uint8_line (char * pref ,const uint8_t * x ,uint32_t n ) { 16char str [1024 ],* p = str ,* p_end = str + sizeof (str ); 17p += snprintf (p ,p_end - p ,"%s: " ,pref ); 18for (int i = 0 ;i < n && p < p_end ;i ++ ) { 19p += snprintf (p ,p_end - p ,"%d, " ,x [i ]); 20 } 21FARF (HIGH ,"%s\n" ,str ); 22} 23 24static inline void hex_dump_uint32_line (char * pref ,const uint32_t * x ,uint32_t n ) { 25char str [1024 ],* p = str ,* p_end = str + sizeof (str ); 26p += snprintf (p ,p_end - p ,"%s: " ,pref ); 27for (int i = 0 ;i < n ;i ++ ) { 28p += snprintf (p ,p_end - p ,"%u, " , (unsigned int )x [i ]); 29 } 30FARF (HIGH ,"%s\n" ,str ); 31} 32 33static inline void hex_dump_int32_line (char * pref ,const int32_t * x ,uint32_t n ) { 34char str [1024 ],* p = str ,* p_end = str + sizeof (str ); 35p += snprintf (p ,p_end - p ,"%s: " ,pref ); 36for (int i = 0 ;i < n ;i ++ ) { 37p += snprintf (p ,p_end - p ,"%d, " , (int )x [i ]); 38 } 39FARF (HIGH ,"%s\n" ,str ); 40} 41 42static inline void hex_dump_f16_line (char * pref ,const __fp16 * x ,uint32_t n ) { 43char str [1024 ],* p = str ,* p_end = str + sizeof (str ); 44p += snprintf (p ,p_end - p ,"%s: " ,pref ); 45for (int i = 0 ;i < n ;i ++ ) { 46p += snprintf (p ,p_end - p ,"%.6f, " , (float )x [i ]); 47 } 48FARF (HIGH ,"%s\n" ,str ); 49} 50 51static inline void hex_dump_f32_line (char * pref ,const float * x ,uint32_t n ) { 52char str [1024 ],* p = str ,* p_end = str + sizeof (str ); 53p += snprintf (p ,p_end - p ,"%s: " ,pref ); 54for (int i = 0 ;i < n ;i ++ ) { 55p += snprintf (p ,p_end - p ,"%.6f, " ,x [i ]); 56 } 57FARF (HIGH ,"%s\n" ,str ); 58} 59 60static inline void hex_dump_f32 (char * pref ,const float * x ,uint32_t n ) { 61uint32_t n0 = n /16 ; 62uint32_t n1 = n %16 ; 63 64uint32_t i = 0 ; 65for (;i < n0 ;i ++ ) { 66hex_dump_f32_line (pref ,x + (16 * i ),16 ); 67 } 68if (n1 ) { 69hex_dump_f32_line (pref ,x + (16 * i ),n1 ); 70 } 71} 72 73static inline void hex_dump_f16 (char * pref ,const __fp16 * x ,uint32_t n ) { 74uint32_t n0 = n /16 ; 75uint32_t n1 = n %16 ; 76 77uint32_t i = 0 ; 78for (;i < n0 ;i ++ ) { 79hex_dump_f16_line (pref ,x + (16 * i ),16 ); 80 } 81if (n1 ) { 82hex_dump_f16_line (pref ,x + (16 * i ),n1 ); 83 } 84} 85 86#endif /* HEX_DUMP_H */