okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
b2de2641f
main
1#pragma once 2 3#include "ggml.h" 4 5#ifdef __cplusplus 6extern "C" { 7#endif 8 9struct ggml_metal_buffer_id { 10void * metal ;// id<MTLBuffer> 11size_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 { 48ggml_metal_pipeline_t pipeline ; 49 50int nsg ; 51 52int nr0 ; 53int nr1 ; 54 55size_t smem ; 56 57bool c4 ; 58bool 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_dsv4_hc (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 130struct 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 ); 131struct 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 ); 132struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_scan (ggml_metal_library_t lib ,const struct ggml_tensor * op ,bool tail ); 133struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_scan_ssd_mma (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 134struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_rwkv (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 135struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_gated_delta_net (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 136struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_solve_tri (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 137struct 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 ); 138struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mm (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 139struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mv (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 140struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mm_id_map0 (ggml_metal_library_t lib ,int ne02 ,int ne20 ); 141struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mm_id_amax (ggml_metal_library_t lib ); 142struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mm_id_amax_part (ggml_metal_library_t lib ); 143struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mm_id (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 144struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mv_id (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 145struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_argmax (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 146struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_argsort (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 147struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_argsort_merge (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 148struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_fwht (ggml_metal_library_t lib ,int n ,enum ggml_type tsrc ); 149 150struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_top_k (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 151struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_top_k_radix (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 152struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_top_k_merge (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 153struct 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 ); 154struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_moe_reduce (ggml_metal_library_t lib ,int32_t n_expert_used ); 155struct 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 ); 156struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_bin_one (ggml_metal_library_t lib ,enum ggml_op op ); 157struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_l2_norm (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 158struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_group_norm (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 159struct 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 ); 160struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_norm_scale (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 161struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_rope (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 162struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_im2col (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 163struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_transpose_1d (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 164struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_transpose_2d (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 165struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_col2im_1d (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 166struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_snake (ggml_metal_library_t lib ,enum ggml_type type ); 167struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_2d (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 168struct 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 ); 169struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_3d (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 170struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_upscale (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 171struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_pad (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 172struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_pad_reflect_1d (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 173struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_roll (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 174struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_arange (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 175struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_timestep_embedding (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 176struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_opt_step_adamw (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 177struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_opt_step_sgd (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 178struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_memset (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 179struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_count_equal (ggml_metal_library_t lib ,const struct ggml_tensor * op ); 180 181struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_pad ( 182ggml_metal_library_t lib , 183const struct ggml_tensor * op , 184bool has_mask , 185int32_t ncpsg ); 186 187struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_kv_f16 ( 188ggml_metal_library_t lib , 189const struct ggml_tensor * op ); 190 191struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_blk ( 192ggml_metal_library_t lib , 193const struct ggml_tensor * op , 194int32_t nqptg , 195int32_t ncpsg ); 196 197struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext ( 198ggml_metal_library_t lib , 199const struct ggml_tensor * op , 200bool has_mask , 201bool has_sinks , 202bool has_bias , 203bool has_scap , 204bool has_kvpad , 205int32_t nsg , 206bool use_kv_f16 , 207int32_t ns10 , 208int32_t ns20 ); 209 210struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_vec_idx ( 211ggml_metal_library_t lib , 212const struct ggml_tensor * op ); 213 214struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_vec ( 215ggml_metal_library_t lib , 216const struct ggml_tensor * op , 217bool has_mask , 218bool has_sinks , 219bool has_bias , 220bool has_scap , 221bool has_kvpad , 222bool has_sparse , 223int32_t nqpsg , 224int32_t ne , 225int32_t nsg , 226int32_t nwg , 227bool use_kv_f16 , 228int32_t ns10 , 229int32_t ns20 ); 230 231struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_flash_attn_ext_vec_reduce ( 232ggml_metal_library_t lib , 233const struct ggml_tensor * op , 234int32_t dv , 235int32_t nwg ); 236 237// MTLResidencySet wrapper 238 239typedef void * ggml_metal_rset_t ; 240 241// a collection of residency sets (non-owning) 242typedef struct ggml_metal_rsets * ggml_metal_rsets_t ; 243 244ggml_metal_rsets_t ggml_metal_rsets_init (ggml_metal_device_t dev ); 245void ggml_metal_rsets_free (ggml_metal_rsets_t rsets ); 246 247// 248// device 249// 250 251enum ggml_metal_device_id { 252GGML_METAL_DEVICE_GENERIC = 0 , 253 254GGML_METAL_DEVICE_M1 , 255GGML_METAL_DEVICE_M1_PRO , 256GGML_METAL_DEVICE_M1_MAX , 257GGML_METAL_DEVICE_M1_ULTRA , 258GGML_METAL_DEVICE_M2 , 259GGML_METAL_DEVICE_M2_PRO , 260GGML_METAL_DEVICE_M2_MAX , 261GGML_METAL_DEVICE_M2_ULTRA , 262GGML_METAL_DEVICE_M3 , 263GGML_METAL_DEVICE_M3_PRO , 264GGML_METAL_DEVICE_M3_MAX , 265GGML_METAL_DEVICE_M3_ULTRA , 266GGML_METAL_DEVICE_M4 , 267GGML_METAL_DEVICE_M4_PRO , 268GGML_METAL_DEVICE_M4_MAX , 269GGML_METAL_DEVICE_M5 , 270GGML_METAL_DEVICE_M5_PRO , 271GGML_METAL_DEVICE_M5_MAX , 272GGML_METAL_DEVICE_M5_ULTRA , 273GGML_METAL_DEVICE_A18_PRO , 274}; 275 276const char * ggml_metal_device_id_token (enum ggml_metal_device_id id ); 277 278struct ggml_metal_device_props { 279int device ; 280int device_phys ; 281int device_virt ; 282char name [128 ]; 283char desc [128 ]; 284 285size_t max_buffer_size ; 286size_t max_working_set_size ; 287size_t max_theadgroup_memory_size ; 288 289bool has_simdgroup_reduction ; 290bool has_simdgroup_mm ; 291bool has_unified_memory ; 292bool has_bfloat ; 293bool has_tensor ; 294bool use_residency_sets ; 295bool use_shared_buffers ; 296 297bool supports_gpu_family_apple7 ; 298 299enum ggml_metal_device_id device_id ; 300int gpu_family ; 301 302int op_offload_min_batch_size ; 303}; 304 305typedef struct ggml_metal_event * ggml_metal_event_t ; 306 307void ggml_metal_event_encode_signal (ggml_metal_event_t ev ,ggml_metal_cmd_buf_t cmd_buf ); 308void ggml_metal_event_encode_wait (ggml_metal_event_t ev ,ggml_metal_cmd_buf_t cmd_buf ); 309 310ggml_metal_device_t ggml_metal_device_init (int device ,int n_devices ); 311void ggml_metal_device_free (ggml_metal_device_t dev ); 312 313ggml_metal_device_t ggml_metal_device_get (int device ,int n_devices ); 314 315void * ggml_metal_device_get_obj (ggml_metal_device_t dev );// id<MTLDevice> 316void * ggml_metal_device_get_queue (ggml_metal_device_t dev );// id<MTLCommandQueue> 317 318ggml_metal_library_t ggml_metal_device_get_library (ggml_metal_device_t dev ); 319 320void ggml_metal_device_rsets_add (ggml_metal_device_t dev ,ggml_metal_rset_t rset ); 321void ggml_metal_device_rsets_rm (ggml_metal_device_t dev ,ggml_metal_rset_t rset ); 322 323void ggml_metal_device_rsets_keep_alive (ggml_metal_device_t dev ); 324 325ggml_metal_event_t ggml_metal_device_event_init (ggml_metal_device_t dev ); 326void ggml_metal_device_event_free (ggml_metal_device_t dev ,ggml_metal_event_t ev ); 327void ggml_metal_device_event_synchronize (ggml_metal_device_t dev ,ggml_metal_event_t ev ); 328 329void ggml_metal_device_get_memory (ggml_metal_device_t dev ,size_t * free ,size_t * total ); 330bool ggml_metal_device_supports_op (ggml_metal_device_t dev ,const struct ggml_tensor * op ); 331 332const struct ggml_metal_device_props * ggml_metal_device_get_props (ggml_metal_device_t dev ); 333 334struct ggml_metal_fusion_info ; 335 336// the device-owned fusion debugging context (NULL unless fusion debugging is enabled) 337struct ggml_metal_fusion_info * ggml_metal_device_get_fusion_info (ggml_metal_device_t dev ); 338 339// 340// device buffers 341// 342 343typedef struct ggml_metal_buffer * ggml_metal_buffer_t ; 344 345ggml_metal_buffer_t ggml_metal_buffer_init (ggml_metal_device_t dev ,size_t size ,bool shared ); 346ggml_metal_buffer_t ggml_metal_buffer_map (ggml_metal_device_t dev ,void * ptr ,size_t size ,size_t max_tensor_size ); 347 348void ggml_metal_buffer_free (ggml_metal_buffer_t buf ); 349void * ggml_metal_buffer_get_base (ggml_metal_buffer_t buf ); 350bool ggml_metal_buffer_is_shared (ggml_metal_buffer_t buf ); 351 352void ggml_metal_buffer_memset_tensor (ggml_metal_buffer_t buf ,struct ggml_tensor * tensor ,uint8_t value ,size_t offset ,size_t size ); 353void ggml_metal_buffer_set_tensor (ggml_metal_buffer_t buf ,struct ggml_tensor * tensor ,const void * data ,size_t offset ,size_t size ); 354void ggml_metal_buffer_get_tensor (ggml_metal_buffer_t buf ,const struct ggml_tensor * tensor ,void * data ,size_t offset ,size_t size ); 355bool ggml_metal_buffer_cpy_tensor (ggml_metal_buffer_t buf ,const struct ggml_tensor * src ,struct ggml_tensor * dst ); 356void ggml_metal_buffer_clear (ggml_metal_buffer_t buf ,uint8_t value ); 357 358// finds the Metal buffer that contains the tensor data on the GPU device 359// the assumption is that there is 1-to-1 mapping between the host and device memory buffers, so we can find the 360// Metal buffer based on the host memory pointer 361// 362struct ggml_metal_buffer_id ggml_metal_buffer_get_id (ggml_metal_buffer_t buf ,const struct ggml_tensor * t ); 363 364#ifdef __cplusplus 365} 366#endif