interplane.Get Omega
Read in your language

ggml

[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)

Brought by drakestapleton

branch master Branches Tags History

ggml / src / ggml-hexagon / htp / set-rows-ops.h

56 lines · 1632 bytes Raw Blame History
1#ifndef HTP_SET_ROWS_OPS_H
2#define HTP_SET_ROWS_OPS_H
3
4#include "hex-fastdiv.h"
5#include "htp-tensor.h"
6#include "htp-vtcm.h"
7
8struct htp_set_rows_kernel_params {
9 uint32_t n_threads;
10 uint32_t total_tasks;
11 uint32_t vtcm_size;
12};
13
14struct htp_set_rows_vtcm_layout {
15 size_t total_bytes;
16 size_t off_src0;
17 size_t off_dst;
18
19 size_t src0_bytes_per_thread;
20 size_t dst_bytes_per_thread;
21
22 size_t src0_spad_half_size;
23 size_t dst_spad_half_size;
24};
25
26static inline void htp_set_rows_vtcm_layout_build(
27 struct htp_set_rows_vtcm_layout * L,
28 int dst_type,
29 uint32_t ne00,
30 uint32_t n_threads) {
31
32 size_t src0_row_size = ne00 * sizeof(float);
33 size_t dst_row_size = htp_tensor_get_row_size(dst_type, ne00);
34
35 size_t src0_row_size_aligned = (src0_row_size + 255) & ~255;
36 size_t dst_row_size_aligned = (dst_row_size + 255) & ~255;
37
38 L->src0_spad_half_size = src0_row_size_aligned;
39 L->dst_spad_half_size = dst_row_size_aligned;
40
41 L->src0_bytes_per_thread = src0_row_size_aligned * 2;
42 L->dst_bytes_per_thread = dst_row_size_aligned * 2;
43
44 size_t off = 0;
45 VTCM_LAYOUT_ALLOC(off, off_src0, L->src0_bytes_per_thread * n_threads);
46 VTCM_LAYOUT_ALLOC(off, off_dst, L->dst_bytes_per_thread * n_threads);
47 L->total_bytes = off;
48}
49
50#if defined(__cplusplus)
51static_assert(sizeof(struct htp_set_rows_kernel_params) <= 128, "htp_set_rows_kernel_params is too large for kernel_params blob");
52#else
53_Static_assert(sizeof(struct htp_set_rows_kernel_params) <= 128, "htp_set_rows_kernel_params is too large for kernel_params blob");
54#endif
55
56#endif // HTP_SET_ROWS_OPS_H