@@ -7,92 +7,14 @@ extern "C" {
77#endif
88
99//
10- // MTLFunctionConstantValues wrapper
11- //
12-
13- typedef struct ggml_metal_cv * ggml_metal_cv_t ;
14-
15- ggml_metal_cv_t ggml_metal_cv_init (void );
16- void ggml_metal_cv_free (ggml_metal_cv_t cv );
17-
18- void ggml_metal_cv_set_int32 (ggml_metal_cv_t cv , int32_t value , int32_t idx );
19- void ggml_metal_cv_set_bool (ggml_metal_cv_t cv , bool value , int32_t idx );
20-
21- //
22- // MTLComputePipelineState wrapper
23- //
24-
25- typedef struct ggml_metal_pipeline * ggml_metal_pipeline_t ;
26-
27- ggml_metal_pipeline_t ggml_metal_pipeline_init (void );
28- void ggml_metal_pipeline_free (ggml_metal_pipeline_t pipeline );
29-
30- void ggml_metal_pipeline_set_nsg (ggml_metal_pipeline_t pipeline , int nsg );
31- int ggml_metal_pipeline_get_nsg (ggml_metal_pipeline_t pipeline );
32-
33- void ggml_metal_pipeline_set_nr0 (ggml_metal_pipeline_t pipeline , int nr0 );
34- int ggml_metal_pipeline_get_nr0 (ggml_metal_pipeline_t pipeline );
35-
36- void ggml_metal_pipeline_set_nr1 (ggml_metal_pipeline_t pipeline , int nr1 );
37- int ggml_metal_pipeline_get_nr1 (ggml_metal_pipeline_t pipeline );
38-
39- void ggml_metal_pipeline_set_smem (ggml_metal_pipeline_t pipeline , size_t smem );
40- size_t ggml_metal_pipeline_get_smem (ggml_metal_pipeline_t pipeline );
41-
42- int ggml_metal_pipeline_max_theads_per_threadgroup (ggml_metal_pipeline_t pipeline );
43-
44- // a collection of pipelines
45- typedef struct ggml_metal_pipelines * ggml_metal_pipelines_t ;
46-
47- ggml_metal_pipelines_t ggml_metal_pipelines_init (void );
48- void ggml_metal_pipelines_free (ggml_metal_pipelines_t ppls );
49-
50- void ggml_metal_pipelines_add (ggml_metal_pipelines_t ppls , const char * name , ggml_metal_pipeline_t pipeline );
51- ggml_metal_pipeline_t ggml_metal_pipelines_get (ggml_metal_pipelines_t ppls , const char * name );
52-
53- //
54- // MTLCommandBuffer wrapper
55- //
56-
57- typedef void * ggml_metal_cmd_buf_t ;
58-
59- //
60- // MTLComputeCommandEncoder wrapper
61- //
62-
63- typedef struct ggml_metal_encoder * ggml_metal_encoder_t ;
64-
65- ggml_metal_encoder_t ggml_metal_encoder_init (ggml_metal_cmd_buf_t cmd_buf_raw , bool concurrent );
66- void ggml_metal_encoder_free (ggml_metal_encoder_t encoder );
67-
68- void ggml_metal_encoder_debug_group_push (ggml_metal_encoder_t encoder , const char * name );
69- void ggml_metal_encoder_debug_group_pop (ggml_metal_encoder_t encoder );
70-
71- void ggml_metal_encoder_set_pipeline (ggml_metal_encoder_t encoder , ggml_metal_pipeline_t pipeline );
72-
73- void ggml_metal_encoder_set_bytes (ggml_metal_encoder_t encoder , void * data , size_t size , int idx );
74- void ggml_metal_encoder_set_buffer (ggml_metal_encoder_t encoder , struct ggml_metal_buffer_id buffer , int idx );
75-
76- void ggml_metal_encoder_set_threadgroup_memory_size (ggml_metal_encoder_t encoder , size_t size , int idx );
77-
78- void ggml_metal_encoder_dispatch_threadgroups (ggml_metal_encoder_t encoder , int tg0 , int tg1 , int tg2 , int tptg0 , int tptg1 , int tptg2 );
79-
80- void ggml_metal_encoder_memory_barrier (ggml_metal_encoder_t encoder );
81-
82- void ggml_metal_encoder_end_encoding (ggml_metal_encoder_t encoder );
83-
84- //
85- // backend
10+ // backend context
8611//
8712
8813typedef struct ggml_metal * ggml_metal_t ;
8914
90- ggml_metal_t ggml_metal_init (ggml_metal_device_t ctx_dev );
15+ ggml_metal_t ggml_metal_init (ggml_metal_device_t dev );
9116void ggml_metal_free (ggml_metal_t ctx );
9217
93- ggml_metal_pipeline_t ggml_metal_get_pipeline (ggml_metal_t ctx , const char * name );
94- ggml_metal_pipeline_t ggml_metal_compile_pipeline (ggml_metal_t ctx , const char * base , const char * name , ggml_metal_cv_t cv );
95-
9618void ggml_metal_synchronize (ggml_metal_t ctx );
9719
9820void ggml_metal_set_tensor_async (ggml_metal_t ctx , struct ggml_tensor * tensor , const void * data , size_t offset , size_t size );
@@ -112,28 +34,19 @@ void ggml_metal_capture_next_compute(ggml_metal_t ctx);
11234
11335typedef struct ggml_metal_graph_encoder * ggml_metal_graph_encoder_t ;
11436
115- // TODO: tmp
116- #include "ggml-metal-common.h"
117-
118- // TODO: tmp
119- struct ggml_metal_graph_encoder {
120- ggml_metal_t ctx ;
121-
122- const struct ggml_metal_device_props * props_dev ;
123-
124- ggml_metal_encoder_t encoder ;
125-
126- ggml_mem_ranges_t mem_ranges ;
37+ ggml_metal_library_t ggml_metal_graph_encoder_get_lib (ggml_metal_graph_encoder_t ctx );
38+ ggml_metal_encoder_t ggml_metal_graph_encoder_get_enc (ggml_metal_graph_encoder_t ctx );
39+ struct ggml_cgraph * ggml_metal_graph_encoder_get_gf (ggml_metal_graph_encoder_t ctx );
12740
128- struct ggml_cgraph * gf ;
41+ const struct ggml_metal_device_props * ggml_metal_graph_encoder_get_props_dev ( ggml_metal_graph_encoder_t ctx ) ;
12942
130- int idx_start ;
131- int idx_end ;
43+ int ggml_metal_graph_encoder_get_idx_start ( ggml_metal_graph_encoder_t ctx ) ;
44+ int ggml_metal_graph_encoder_get_idx_end ( ggml_metal_graph_encoder_t ctx ) ;
13245
133- bool use_fusion ;
46+ bool ggml_metal_graph_encoder_get_use_fusion ( ggml_metal_graph_encoder_t ctx ) ;
13447
135- int debug_fusion ;
136- } ;
48+ int ggml_metal_graph_encoder_get_debug_fusion ( ggml_metal_graph_encoder_t ctx ) ;
49+ int ggml_metal_graph_encoder_get_debug_graph ( ggml_metal_graph_encoder_t ctx ) ;
13750
13851bool ggml_metal_graph_encoder_concurrency_reset (ggml_metal_graph_encoder_t ctx );
13952bool ggml_metal_graph_encoder_concurrency_check (ggml_metal_graph_encoder_t ctx , const struct ggml_tensor * node );
0 commit comments