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/concat-ops.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 / concat-ops.h` 74 lines ยท 2420 bytes Raw Blame History 1 #ifndef HTP_CONCAT_OPS_H 2 #define HTP_CONCAT_OPS_H 3 4 #include "hex-common.h" 5 #include "hex-fastdiv.h" 6 #include "htp-vtcm.h" 7 #include "gather-rows.h" 8 #include 9 10 enum htp_concat_kernel_type { 11 HTP_CONCAT_KERNEL_UNSUPPORTED = 0, 12 HTP_CONCAT_KERNEL_REGULAR = 1, 13 HTP_CONCAT_KERNEL_TRANSPOSED = 2, 14 HTP_CONCAT_KERNEL_GATHER_ROWS = 3, 15 }; 16 17 struct htp_concat_transposed_params { 18 struct fastdiv_values div_ne2; 19 }; 20 21 struct htp_concat_kernel_params { 22 uint8_t kernel_type; 23 uint8_t dim; 24 uint8_t n_threads; 25 uint8_t pad; 26 27 uint32_t vtcm_size; 28 29 union { 30 struct htp_concat_transposed_params transposed; 31 struct htp_gather_rows_params gather; 32 } u; 33 }; 34 35 #if defined(__cplusplus) 36 static_assert(sizeof(struct htp_concat_kernel_params) <= 128, "htp_concat_kernel_params is too large for kernel_params blob"); 37 #else 38 _Static_assert(sizeof(struct htp_concat_kernel_params) <= 128, "htp_concat_kernel_params is too large for kernel_params blob"); 39 #endif 40 41 struct htp_concat_transposed_vtcm_layout { 42 uint32_t src0_spad_size_per_thread; 43 uint32_t src1_spad_size_per_thread; 44 size_t off_spad0; 45 size_t off_spad1; 46 uint32_t total_bytes; 47 }; 48 49 static inline void htp_concat_transposed_vtcm_layout_build( 50 struct htp_concat_transposed_vtcm_layout * L, 51 uint32_t src0_ne0, 52 uint32_t src1_ne0, 53 uint32_t type_size, 54 uint32_t n_threads) { 55 56 // src1_ne0 is processed in chunks of block_cols tokens, so VTCM does not grow with the batch 57 uint32_t block_rows = 128; 58 uint32_t block_cols = (type_size == 4) ? 256 : 512; 59 // +1 element spreads the gather lanes across VTCM, so they do not serialize on one path 60 uint32_t spad1_stride = block_rows * type_size + type_size; 61 uint32_t block_cols_padded = MIN(hex_round_up(src1_ne0, (type_size == 4) ? 32 : 64), block_cols); 62 uint32_t spad0_row_bytes = hex_round_up(src0_ne0 * type_size, 128) + block_cols_padded * type_size; 63 64 // double-buffered: two slots per thread 65 L->src0_spad_size_per_thread = 2 * block_rows * spad0_row_bytes; 66 L->src1_spad_size_per_thread = 2 * block_cols_padded * spad1_stride; 67 68 size_t off = 0; 69 VTCM_LAYOUT_ALLOC(off, off_spad0, (size_t) n_threads * L->src0_spad_size_per_thread); 70 VTCM_LAYOUT_ALLOC(off, off_spad1, (size_t) n_threads * L->src1_spad_size_per_thread); 71 L->total_bytes = (uint32_t) off; 72 } 73 74 #endif // HTP_CONCAT_OPS_H