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/glu-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 / glu-ops.h` 76 lines ยท 2235 bytes Raw Blame History 1 #ifndef HTP_GLU_OPS_H 2 #define HTP_GLU_OPS_H 3 4 #include "hex-common.h" 5 #include "htp-ops.h" 6 #include "htp-vtcm.h" 7 #include 8 9 struct htp_glu_kernel_params { 10 uint32_t n_threads; 11 uint32_t vtcm_row_per_thread; 12 uint32_t vtcm_size; 13 }; 14 15 #if defined(__cplusplus) 16 static_assert(sizeof(struct htp_glu_kernel_params) <= 128, "htp_glu_kernel_params is too large for kernel_params blob"); 17 #else 18 _Static_assert(sizeof(struct htp_glu_kernel_params) <= 128, "htp_glu_kernel_params is too large for kernel_params blob"); 19 #endif 20 21 static inline bool htp_op_is_glu(uint32_t opcode) { 22 switch (opcode) { 23 case HTP_OP_GLU_SWIGLU: 24 case HTP_OP_GLU_SWIGLU_OAI: 25 case HTP_OP_GLU_SWIGLU_CLAMP: 26 case HTP_OP_GLU_GEGLU: 27 case HTP_OP_GLU_GEGLU_QUICK: 28 case HTP_OP_GLU_GEGLU_ERF: 29 case HTP_OP_GLU_REGLU: 30 case HTP_OP_GLU_SIGMOID: 31 return true; 32 default: 33 return false; 34 } 35 } 36 37 struct htp_glu_vtcm_layout { 38 size_t total_bytes; 39 size_t off_src0; 40 size_t off_src1; 41 size_t off_dst; 42 43 size_t row_size_aligned; 44 size_t src0_bytes_per_thread; 45 size_t src1_bytes_per_thread; 46 size_t dst_bytes_per_thread; 47 48 uint32_t vtcm_row_per_thread; 49 uint32_t block; 50 }; 51 52 static inline void htp_glu_vtcm_layout_build( 53 struct htp_glu_vtcm_layout * L, 54 size_t dst_row_size, 55 uint32_t n_threads, 56 uint32_t vtcm_row_per_thread 57 ) { 58 const size_t row_size_aligned = hex_round_up(dst_row_size, 128); 59 60 L->row_size_aligned = row_size_aligned; 61 L->vtcm_row_per_thread = vtcm_row_per_thread; 62 L->block = vtcm_row_per_thread >> 1; 63 64 L->src0_bytes_per_thread = row_size_aligned * vtcm_row_per_thread; 65 L->src1_bytes_per_thread = row_size_aligned * vtcm_row_per_thread; 66 L->dst_bytes_per_thread = row_size_aligned * vtcm_row_per_thread; 67 68 size_t off = 0; 69 VTCM_LAYOUT_ALLOC(off, off_src0, L->src0_bytes_per_thread * n_threads); 70 VTCM_LAYOUT_ALLOC(off, off_src1, L->src1_bytes_per_thread * n_threads); 71 VTCM_LAYOUT_ALLOC(off, off_dst, L->dst_bytes_per_thread * n_threads); 72 73 L->total_bytes = off; 74 } 75 76 #endif // HTP_GLU_OPS_H