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-metal / ggml-metal-device.h

384 lines · 21997 bytes Raw Blame History
1#pragma once
2
3#include "ggml.h"
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9struct ggml_metal_buffer_id {
10 void * metal; // id<MTLBuffer>
11 size_t offs;
12};
13
14typedef struct ggml_metal_device * ggml_metal_device_t;
15
16//
17// MTLFunctionConstantValues wrapper
18//
19
20typedef struct ggml_metal_cv * ggml_metal_cv_t;
21
22ggml_metal_cv_t ggml_metal_cv_init(void);
23void ggml_metal_cv_free(ggml_metal_cv_t cv);
24
25void ggml_metal_cv_set_int16(ggml_metal_cv_t cv, int16_t value, int32_t idx);
26void ggml_metal_cv_set_int32(ggml_metal_cv_t cv, int32_t value, int32_t idx);
27void ggml_metal_cv_set_bool (ggml_metal_cv_t cv, bool value, int32_t idx);
28
29//
30// MTLComputePipelineState wrapper
31//
32
33typedef struct ggml_metal_pipeline * ggml_metal_pipeline_t;
34
35ggml_metal_pipeline_t ggml_metal_pipeline_init(void);
36void ggml_metal_pipeline_free(ggml_metal_pipeline_t pipeline);
37
38// a collection of pipelines
39typedef struct ggml_metal_pipelines * ggml_metal_pipelines_t;
40
41ggml_metal_pipelines_t ggml_metal_pipelines_init(void);
42void ggml_metal_pipelines_free(ggml_metal_pipelines_t ppls);
43
44void ggml_metal_pipelines_add(ggml_metal_pipelines_t ppls, const char * name, ggml_metal_pipeline_t pipeline);
45ggml_metal_pipeline_t ggml_metal_pipelines_get(ggml_metal_pipelines_t ppls, const char * name);
46
47struct ggml_metal_pipeline_with_params {
48 ggml_metal_pipeline_t pipeline;
49
50 int nsg;
51
52 int nr0;
53 int nr1;
54
55 size_t smem;
56
57 bool c4;
58 bool cnt;
59};
60
61int ggml_metal_pipeline_max_theads_per_threadgroup(struct ggml_metal_pipeline_with_params pipeline);
62
63//
64// MTLCommandBuffer wrapper
65//
66
67typedef void * ggml_metal_cmd_buf_t;
68
69//
70// MTLComputeCommandEncoder wrapper
71//
72
73typedef struct ggml_metal_encoder * ggml_metal_encoder_t;
74
75ggml_metal_encoder_t ggml_metal_encoder_init(ggml_metal_cmd_buf_t cmd_buf_raw, bool concurrent);
76void ggml_metal_encoder_free(ggml_metal_encoder_t encoder);
77
78void ggml_metal_encoder_debug_group_push(ggml_metal_encoder_t encoder, const char * name);
79void ggml_metal_encoder_debug_group_pop (ggml_metal_encoder_t encoder);
80
81void ggml_metal_encoder_set_pipeline(ggml_metal_encoder_t encoder, struct ggml_metal_pipeline_with_params pipeline);
82
83void ggml_metal_encoder_set_bytes (ggml_metal_encoder_t encoder, void * data, size_t size, int idx);
84void ggml_metal_encoder_set_buffer(ggml_metal_encoder_t encoder, struct ggml_metal_buffer_id buffer, int idx);
85
86void ggml_metal_encoder_set_threadgroup_memory_size(ggml_metal_encoder_t encoder, size_t size, int idx);
87
88void ggml_metal_encoder_dispatch_threadgroups(ggml_metal_encoder_t encoder, int tg0, int tg1, int tg2, int tptg0, int tptg1, int tptg2);
89
90void ggml_metal_encoder_memory_barrier(ggml_metal_encoder_t encoder);
91
92void ggml_metal_encoder_end_encoding(ggml_metal_encoder_t encoder);
93
94//
95// MTLLibrary wrapper
96//
97
98typedef struct ggml_metal_library * ggml_metal_library_t;
99
100ggml_metal_library_t ggml_metal_library_init (ggml_metal_device_t dev);
101ggml_metal_library_t ggml_metal_library_init_from_source(ggml_metal_device_t dev, const char * source, bool verbose);
102
103void ggml_metal_library_free(ggml_metal_library_t lib);
104
105ggml_metal_device_t ggml_metal_library_get_device(ggml_metal_library_t lib);
106
107struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline (ggml_metal_library_t lib, const char * name);
108struct ggml_metal_pipeline_with_params ggml_metal_library_compile_pipeline(ggml_metal_library_t lib, const char * base, const char * name, ggml_metal_cv_t cv);
109
110struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_base (ggml_metal_library_t lib, enum ggml_op op);
111struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_cpy (ggml_metal_library_t lib, enum ggml_type tsrc, enum ggml_type tdst);
112struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_pool_1d (ggml_metal_library_t lib, const struct ggml_tensor * op, enum ggml_op_pool op_pool);
113struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_pool_2d (ggml_metal_library_t lib, const struct ggml_tensor * op, enum ggml_op_pool op_pool);
114struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_get_rows (ggml_metal_library_t lib, enum ggml_type tsrc);
115struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_set_rows (ggml_metal_library_t lib, const struct ggml_tensor * op);
116struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_diag (ggml_metal_library_t lib, const struct ggml_tensor * op);
117struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_repeat (ggml_metal_library_t lib, enum ggml_type tsrc);
118struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_concat (ggml_metal_library_t lib, enum ggml_type tsrc);
119struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_unary (ggml_metal_library_t lib, const struct ggml_tensor * op);
120struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_silu_back (ggml_metal_library_t lib, const struct ggml_tensor * op);
121struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_glu (ggml_metal_library_t lib, const struct ggml_tensor * op);
122struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_sum (ggml_metal_library_t lib, const struct ggml_tensor * op);
123struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_sum_rows (ggml_metal_library_t lib, const struct ggml_tensor * op);
124struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_cumsum_blk (ggml_metal_library_t lib, const struct ggml_tensor * op);
125struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_cumsum_add (ggml_metal_library_t lib, const struct ggml_tensor * op);
126struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_tri (ggml_metal_library_t lib, const struct ggml_tensor * op);
127struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_soft_max (ggml_metal_library_t lib, const struct ggml_tensor * op);
128struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_lightning_indexer (ggml_metal_library_t lib, const struct ggml_tensor * op);
129struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_top_k_mask (ggml_metal_library_t lib, const struct ggml_tensor * op, bool fill, bool has_score, bool has_blocks, bool has_extra, bool vec);
130struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_dsv4_hc (ggml_metal_library_t lib, const struct ggml_tensor * op);
131struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_conv (ggml_metal_library_t lib, const struct ggml_tensor * op, int32_t nc, bool use_silu);
132struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_conv_batched (ggml_metal_library_t lib, const struct ggml_tensor * op, int ssm_conv_bs, int32_t nc, bool use_silu);
133struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_scan (ggml_metal_library_t lib, const struct ggml_tensor * op, bool tail);
134struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_scan_ssd_mma (ggml_metal_library_t lib, const struct ggml_tensor * op);
135struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_rwkv (ggml_metal_library_t lib, const struct ggml_tensor * op);
136struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_gated_delta_net (ggml_metal_library_t lib, const struct ggml_tensor * op);
137struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_solve_tri (ggml_metal_library_t lib, const struct ggml_tensor * op);
138struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mv_ext (ggml_metal_library_t lib, const struct ggml_tensor * op, int nsg, int nxpsg, int r1ptg);
139struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mv_mma (ggml_metal_library_t lib, const struct ggml_tensor * op, int nsg, int nt, int rt, bool add);
140struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mv_mma_auto (ggml_metal_library_t lib, const struct ggml_tensor * op, bool add);
141struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mm (ggml_metal_library_t lib, const struct ggml_tensor * op);
142struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mv (ggml_metal_library_t lib, const struct ggml_tensor * op);
143struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mm_id_map0 (ggml_metal_library_t lib, int ne02, int ne20);
144struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mm_id_zero (ggml_metal_library_t lib);
145struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mm_id (ggml_metal_library_t lib, const struct ggml_tensor * op);
146struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mv_id (ggml_metal_library_t lib, const struct ggml_tensor * op);
147struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_argmax (ggml_metal_library_t lib, const struct ggml_tensor * op);
148struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_argmax_part (ggml_metal_library_t lib);
149struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_argmax_final (ggml_metal_library_t lib);
150struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_argsort (ggml_metal_library_t lib, const struct ggml_tensor * op);
151struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_argsort_merge (ggml_metal_library_t lib, const struct ggml_tensor * op);
152struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_fwht (ggml_metal_library_t lib, int n, enum ggml_type tsrc);
153
154struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_top_k (ggml_metal_library_t lib, const struct ggml_tensor * op);
155struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_top_k_radix (ggml_metal_library_t lib, const struct ggml_tensor * op);
156struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_top_k_merge (ggml_metal_library_t lib, const struct ggml_tensor * op);
157struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_topk_moe (ggml_metal_library_t lib, int32_t n_expert, int32_t top_k, bool with_norm);
158struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_moe_reduce (ggml_metal_library_t lib, int32_t n_expert_used);
159struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_bin (ggml_metal_library_t lib, const struct ggml_tensor * op, int32_t n_fuse);
160struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_bin_one (ggml_metal_library_t lib, enum ggml_op op);
161struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_l2_norm (ggml_metal_library_t lib, const struct ggml_tensor * op);
162struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_group_norm (ggml_metal_library_t lib, const struct ggml_tensor * op);
163struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_norm (ggml_metal_library_t lib, const struct ggml_tensor * op, int32_t n_fuse);
164struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_norm_scale (ggml_metal_library_t lib, const struct ggml_tensor * op);
165struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_rope (ggml_metal_library_t lib, const struct ggml_tensor * op);
166struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_im2col (ggml_metal_library_t lib, const struct ggml_tensor * op);
167struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_transpose_1d (ggml_metal_library_t lib, const struct ggml_tensor * op);
168struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_transpose_2d (ggml_metal_library_t lib, const struct ggml_tensor * op);
169struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_col2im_1d (ggml_metal_library_t lib, const struct ggml_tensor * op);
170struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_snake (ggml_metal_library_t lib, enum ggml_type type);
171struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_2d (ggml_metal_library_t lib, const struct ggml_tensor * op);
172struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_2d_dw (ggml_metal_library_t lib, const struct ggml_tensor * op, bool tiled);
173struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_3d (ggml_metal_library_t lib, const struct ggml_tensor * op);
174struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_upscale (ggml_metal_library_t lib, const struct ggml_tensor * op);
175struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_pad (ggml_metal_library_t lib, const struct ggml_tensor * op);
176struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_pad_reflect_1d (ggml_metal_library_t lib, const struct ggml_tensor * op);
177struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_roll (ggml_metal_library_t lib, const struct ggml_tensor * op);
178struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_arange (ggml_metal_library_t lib, const struct ggml_tensor * op);
179struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_timestep_embedding(ggml_metal_library_t lib, const struct ggml_tensor * op);
180struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_opt_step_adamw (ggml_metal_library_t lib, const struct ggml_tensor * op);
181struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_opt_step_sgd (ggml_metal_library_t lib, const struct ggml_tensor * op);
182struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_memset (ggml_metal_library_t lib, const struct ggml_tensor * op);
183struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_count_equal (ggml_metal_library_t lib, const struct ggml_tensor * op);
184
185struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_pad(
186 ggml_metal_library_t lib,
187 const struct ggml_tensor * op,
188 bool has_mask,
189 int32_t ncpsg);
190
191struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_kv_f16(
192 ggml_metal_library_t lib,
193 const struct ggml_tensor * op);
194
195struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_blk(
196 ggml_metal_library_t lib,
197 const struct ggml_tensor * op,
198 int32_t nqptg,
199 int32_t ncpsg);
200
201struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_tensor(
202 ggml_metal_library_t lib,
203 const struct ggml_tensor * op,
204 bool has_mask,
205 bool has_sinks,
206 bool has_bias,
207 bool has_scap);
208
209struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext(
210 ggml_metal_library_t lib,
211 const struct ggml_tensor * op,
212 bool has_mask,
213 bool has_sinks,
214 bool has_bias,
215 bool has_scap,
216 bool has_kvpad,
217 int32_t nsg,
218 bool use_kv_f16,
219 int32_t ns10,
220 int32_t ns20);
221
222struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_rows(
223 ggml_metal_library_t lib,
224 const struct ggml_tensor * op);
225
226struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_vec_idx(
227 ggml_metal_library_t lib,
228 const struct ggml_tensor * op);
229
230struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_vec(
231 ggml_metal_library_t lib,
232 const struct ggml_tensor * op,
233 bool has_mask,
234 bool has_sinks,
235 bool has_bias,
236 bool has_scap,
237 bool has_kvpad,
238 bool has_sparse,
239 bool has_rows,
240 int32_t nqpsg,
241 int32_t ne,
242 int32_t nsg,
243 int32_t nwg,
244 bool use_kv_f16,
245 int32_t ns10,
246 int32_t ns20);
247
248struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_vec_reduce(
249 ggml_metal_library_t lib,
250 const struct ggml_tensor * op,
251 int32_t dv,
252 int32_t nwg);
253
254// MTLResidencySet wrapper
255
256typedef void * ggml_metal_rset_t;
257
258// a collection of residency sets (non-owning)
259typedef struct ggml_metal_rsets * ggml_metal_rsets_t;
260
261ggml_metal_rsets_t ggml_metal_rsets_init(ggml_metal_device_t dev);
262void ggml_metal_rsets_free(ggml_metal_rsets_t rsets);
263
264//
265// device
266//
267
268enum ggml_metal_device_id {
269 GGML_METAL_DEVICE_GENERIC = 0,
270
271 GGML_METAL_DEVICE_M1,
272 GGML_METAL_DEVICE_M1_PRO,
273 GGML_METAL_DEVICE_M1_MAX,
274 GGML_METAL_DEVICE_M1_ULTRA,
275 GGML_METAL_DEVICE_M2,
276 GGML_METAL_DEVICE_M2_PRO,
277 GGML_METAL_DEVICE_M2_MAX,
278 GGML_METAL_DEVICE_M2_ULTRA,
279 GGML_METAL_DEVICE_M3,
280 GGML_METAL_DEVICE_M3_PRO,
281 GGML_METAL_DEVICE_M3_MAX,
282 GGML_METAL_DEVICE_M3_ULTRA,
283 GGML_METAL_DEVICE_M4,
284 GGML_METAL_DEVICE_M4_PRO,
285 GGML_METAL_DEVICE_M4_MAX,
286 GGML_METAL_DEVICE_M5,
287 GGML_METAL_DEVICE_M5_PRO,
288 GGML_METAL_DEVICE_M5_MAX,
289 GGML_METAL_DEVICE_M5_ULTRA,
290 GGML_METAL_DEVICE_A18_PRO,
291};
292
293const char * ggml_metal_device_id_token(enum ggml_metal_device_id id);
294
295struct ggml_metal_device_props {
296 int device;
297 int device_phys;
298 int device_virt;
299 char name[128];
300 char desc[128];
301
302 size_t max_buffer_size;
303 size_t max_working_set_size;
304 size_t max_theadgroup_memory_size;
305
306 bool has_simdgroup_reduction;
307 bool has_simdgroup_mm;
308 bool has_unified_memory;
309 bool has_bfloat;
310 bool has_tensor;
311 bool use_residency_sets;
312 bool use_shared_buffers;
313
314 enum ggml_metal_device_id device_id;
315 int gpu_family;
316
317 int op_offload_min_batch_size;
318};
319
320typedef struct ggml_metal_event * ggml_metal_event_t;
321
322void ggml_metal_event_encode_signal(ggml_metal_event_t ev, ggml_metal_cmd_buf_t cmd_buf);
323void ggml_metal_event_encode_wait (ggml_metal_event_t ev, ggml_metal_cmd_buf_t cmd_buf);
324
325ggml_metal_device_t ggml_metal_device_init(int device, int n_devices);
326void ggml_metal_device_free(ggml_metal_device_t dev);
327
328ggml_metal_device_t ggml_metal_device_get(int device, int n_devices);
329
330void * ggml_metal_device_get_obj (ggml_metal_device_t dev); // id<MTLDevice>
331void * ggml_metal_device_get_queue(ggml_metal_device_t dev); // id<MTLCommandQueue>
332
333ggml_metal_library_t ggml_metal_device_get_library(ggml_metal_device_t dev);
334
335void ggml_metal_device_rsets_add(ggml_metal_device_t dev, ggml_metal_rset_t rset);
336void ggml_metal_device_rsets_rm (ggml_metal_device_t dev, ggml_metal_rset_t rset);
337
338void ggml_metal_device_rsets_keep_alive(ggml_metal_device_t dev);
339
340ggml_metal_event_t ggml_metal_device_event_init(ggml_metal_device_t dev);
341void ggml_metal_device_event_free(ggml_metal_device_t dev, ggml_metal_event_t ev);
342void ggml_metal_device_event_synchronize(ggml_metal_device_t dev, ggml_metal_event_t ev);
343
344void ggml_metal_device_get_memory(ggml_metal_device_t dev, size_t * free, size_t * total);
345bool ggml_metal_device_supports_op(ggml_metal_device_t dev, const struct ggml_tensor * op);
346
347const struct ggml_metal_device_props * ggml_metal_device_get_props(ggml_metal_device_t dev);
348
349struct ggml_metal_fusion_info;
350
351// the device-owned fusion debugging context (NULL unless fusion debugging is enabled)
352struct ggml_metal_fusion_info * ggml_metal_device_get_fusion_info(ggml_metal_device_t dev);
353
354//
355// device buffers
356//
357
358typedef struct ggml_metal_buffer * ggml_metal_buffer_t;
359
360ggml_metal_buffer_t ggml_metal_buffer_init(ggml_metal_device_t dev, size_t size, bool shared);
361ggml_metal_buffer_t ggml_metal_buffer_map (ggml_metal_device_t dev, void * ptr, size_t size, size_t max_tensor_size);
362
363void ggml_metal_buffer_free (ggml_metal_buffer_t buf);
364void * ggml_metal_buffer_get_base (ggml_metal_buffer_t buf);
365bool ggml_metal_buffer_is_shared(ggml_metal_buffer_t buf);
366
367void ggml_metal_buffer_memset_tensor(ggml_metal_buffer_t buf, struct ggml_tensor * tensor, uint8_t value, size_t offset, size_t size);
368void ggml_metal_buffer_set_tensor (ggml_metal_buffer_t buf, struct ggml_tensor * tensor, const void * data, size_t offset, size_t size);
369void ggml_metal_buffer_get_tensor (ggml_metal_buffer_t buf, const struct ggml_tensor * tensor, void * data, size_t offset, size_t size);
370void ggml_metal_buffer_set_tensor_n (ggml_metal_buffer_t buf, struct ggml_tensor * const * tensors, const void * const * data, const size_t * offsets, const size_t * sizes, size_t n_tensors);
371void ggml_metal_buffer_get_tensor_n (ggml_metal_buffer_t buf, const struct ggml_tensor * const * tensors, void * const * data, const size_t * offsets, const size_t * sizes, size_t n_tensors);
372bool ggml_metal_buffer_cpy_tensor (ggml_metal_buffer_t buf, const struct ggml_tensor * src, struct ggml_tensor * dst);
373bool ggml_metal_buffer_cpy_tensor_n (ggml_metal_buffer_t buf, const struct ggml_tensor * const * srcs, struct ggml_tensor * const * dsts, size_t n_tensors);
374void ggml_metal_buffer_clear (ggml_metal_buffer_t buf, uint8_t value);
375
376// finds the Metal buffer that contains the tensor data on the GPU device
377// the assumption is that there is 1-to-1 mapping between the host and device memory buffers, so we can find the
378// Metal buffer based on the host memory pointer
379//
380struct ggml_metal_buffer_id ggml_metal_buffer_get_id(ggml_metal_buffer_t buf, const struct ggml_tensor * t);
381
382#ifdef __cplusplus
383}
384#endif