Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-hexagon/htp/hvx-dump.h # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-hexagon / htp / hvx-dump.h` 129 lines ยท 3213 bytes Raw Blame History 1 #ifndef HVX_DUMP_H 2 #define HVX_DUMP_H 3 4 #include 5 6 #include 7 #include 8 9 #include "hex-utils.h" 10 #include "hvx-types.h" 11 12 static void hvx_vec_dump_f16_n(char * pref, HVX_Vector v, uint32_t n) { 13 HVX_VectorAlias u = { .v = v }; 14 15 const uint32_t n0 = n / 16; 16 const uint32_t n1 = n % 16; 17 int i = 0; 18 for (; i < n0; i++) { 19 hex_dump_f16_line(pref, u.fp16 + (16 * i), 16); 20 } 21 if (n1) { 22 hex_dump_f16_line(pref, u.fp16 + (16 * i), n1); 23 } 24 } 25 26 static void hvx_vec_dump_f16(char * pref, HVX_Vector v) { 27 hvx_vec_dump_f16_n(pref, v, 64); 28 } 29 30 static void hvx_vec_dump_f32_n(char * pref, HVX_Vector v, uint32_t n) { 31 HVX_VectorAlias u = { .v = v }; 32 33 const uint32_t n0 = n / 16; 34 const uint32_t n1 = n % 16; 35 int i = 0; 36 for (; i < n0; i++) { 37 hex_dump_f32_line(pref, u.fp32 + (16 * i), 16); 38 } 39 if (n1) { 40 hex_dump_f32_line(pref, u.fp32 + (16 * i), n1); 41 } 42 } 43 44 static void hvx_vec_dump_f32_hmt(char * pref, HVX_Vector v) { 45 union { 46 HVX_Vector v; 47 float d[32]; 48 } u = { .v = v }; 49 50 FARF(HIGH, "%s: %.6f %.6f %.6f %.6f ... %.6f %.6f %.6f %.6f ... %.6f %.6f %.6f %.6f\n", pref, u.d[0], u.d[1], 51 u.d[2], u.d[3], u.d[12], u.d[13], u.d[14], u.d[15], u.d[28], u.d[29], u.d[30], u.d[31]); 52 } 53 54 static void hvx_vec_dump_f32(char * pref, HVX_Vector v) { 55 hvx_vec_dump_f32_n(pref, v, 32); 56 } 57 58 static void hvx_vec_dump_int32(char * pref, HVX_Vector v) { 59 union { 60 HVX_Vector v; 61 int32_t d[32]; 62 } u = { .v = v }; 63 64 for (int i = 0; i < 32 / 16; i++) { 65 hex_dump_int32_line(pref, u.d + (16 * i), 16); 66 } 67 } 68 69 static void hvx_vec_dump_int32_hmt(char * pref, HVX_Vector v) { 70 union { 71 HVX_Vector v; 72 int32_t d[32]; 73 } u = { .v = v }; 74 75 FARF(HIGH, "%s: %d %d %d %d ... %d %d %d %d ... %d %d %d %d\n", pref, u.d[0], u.d[1], u.d[2], u.d[3], u.d[12], 76 u.d[13], u.d[14], u.d[15], u.d[28], u.d[29], u.d[30], u.d[31]); 77 } 78 79 static void hvx_vec_dump_int8_hmt(char * pref, HVX_Vector v) { 80 union { 81 HVX_Vector v; 82 int8_t d[128]; 83 } u = { .v = v }; 84 85 FARF(HIGH, "%s: %d %d %d %d ... %d %d %d %d ... %d %d %d %d\n", pref, u.d[0], u.d[1], u.d[2], u.d[3], u.d[60], 86 u.d[61], u.d[62], u.d[63], u.d[124], u.d[125], u.d[126], u.d[127]); 87 } 88 89 static void hvx_vec_dump_int8(char * pref, HVX_Vector v) { 90 union { 91 HVX_Vector v; 92 int8_t d[128]; 93 } u = { .v = v }; 94 95 for (int i = 0; i < 128 / 16; i++) { 96 hex_dump_int8_line(pref, u.d + (16 * i), 16); 97 } 98 } 99 100 static void hvx_vec_dump_uint8(char * pref, HVX_Vector v) { 101 union { 102 HVX_Vector v; 103 uint8_t d[128]; 104 } u = { .v = v }; 105 106 for (int i = 0; i < 128 / 16; i++) { 107 hex_dump_uint8_line(pref, u.d + (16 * i), 16); 108 } 109 } 110 111 static bool hvx_vec_eq(HVX_Vector v0, HVX_Vector v1, size_t n) { 112 typedef union { 113 HVX_Vector v; 114 int8_t d[128]; 115 } U; 116 117 U u0 = { .v = v0 }; 118 U u1 = { .v = v1 }; 119 120 for (int i = 0; i < n; i++) { 121 if (u0.d[i] != u1.d[i]) { 122 return false; 123 } 124 } 125 126 return true; 127 } 128 129 #endif /* HVX_DUMP_H */