Skip to content

Commit aa07dfa

Browse files
ggerganovarthw
authored andcommitted
metal : fix struct name (ggml/912)
ggml-ci
1 parent 3902dc3 commit aa07dfa

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

ggml/src/ggml-metal.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
GGML_METAL_KERNEL_TYPE_COUNT
211211
};
212212

213-
struct ggml_metal_context {
213+
struct ggml_backend_metal_context {
214214
int n_cb;
215215

216216
id<MTLDevice> device;
@@ -293,7 +293,7 @@ static void ggml_metal_log(enum ggml_log_level level, const char * format, ...){
293293
return data;
294294
}
295295

296-
static struct ggml_metal_context * ggml_metal_init(int n_cb) {
296+
static struct ggml_backend_metal_context * ggml_metal_init(int n_cb) {
297297
GGML_METAL_LOG_INFO("%s: allocating\n", __func__);
298298

299299
#if TARGET_OS_OSX && !GGML_METAL_NDEBUG
@@ -310,7 +310,7 @@ static void ggml_metal_log(enum ggml_log_level level, const char * format, ...){
310310
GGML_METAL_LOG_INFO("%s: picking default device: %s\n", __func__, [[device name] UTF8String]);
311311

312312
// Configure context
313-
struct ggml_metal_context * ctx = malloc(sizeof(struct ggml_metal_context));
313+
struct ggml_backend_metal_context * ctx = malloc(sizeof(struct ggml_backend_metal_context));
314314
ctx->device = device;
315315
ctx->n_cb = MIN(n_cb, GGML_METAL_MAX_BUFFERS);
316316
ctx->queue = [ctx->device newCommandQueue];
@@ -672,7 +672,7 @@ static void ggml_metal_log(enum ggml_log_level level, const char * format, ...){
672672
return ctx;
673673
}
674674

675-
static void ggml_metal_free(struct ggml_metal_context * ctx) {
675+
static void ggml_metal_free(struct ggml_backend_metal_context * ctx) {
676676
GGML_METAL_LOG_INFO("%s: deallocating\n", __func__);
677677

678678
for (int i = 0; i < GGML_METAL_KERNEL_TYPE_COUNT; ++i) {
@@ -738,7 +738,7 @@ static void ggml_metal_free(struct ggml_metal_context * ctx) {
738738
return nil;
739739
}
740740

741-
static bool ggml_metal_supports_op(const struct ggml_metal_context * ctx, const struct ggml_tensor * op) {
741+
static bool ggml_metal_supports_op(const struct ggml_backend_metal_context * ctx, const struct ggml_tensor * op) {
742742
for (size_t i = 0, n = 3; i < n; ++i) {
743743
if (op->src[i] != NULL && op->src[i]->type == GGML_TYPE_BF16) {
744744
return false;
@@ -849,7 +849,7 @@ static bool ggml_metal_supports_op(const struct ggml_metal_context * ctx, const
849849
}
850850

851851
static enum ggml_status ggml_metal_graph_compute(
852-
struct ggml_metal_context * ctx,
852+
struct ggml_backend_metal_context * ctx,
853853
struct ggml_cgraph * gf) {
854854

855855
@autoreleasepool {
@@ -3176,7 +3176,7 @@ GGML_CALL ggml_backend_buffer_t ggml_backend_metal_buffer_from_ptr(void * data,
31763176
}
31773177

31783178
GGML_CALL static void ggml_backend_metal_free(ggml_backend_t backend) {
3179-
struct ggml_metal_context * ctx = (struct ggml_metal_context *)backend->context;
3179+
struct ggml_backend_metal_context * ctx = (struct ggml_backend_metal_context *)backend->context;
31803180
ggml_metal_free(ctx);
31813181
free(backend);
31823182
}
@@ -3188,13 +3188,13 @@ GGML_CALL static ggml_backend_buffer_type_t ggml_backend_metal_get_default_buffe
31883188
}
31893189

31903190
GGML_CALL static enum ggml_status ggml_backend_metal_graph_compute(ggml_backend_t backend, struct ggml_cgraph * cgraph) {
3191-
struct ggml_metal_context * metal_ctx = (struct ggml_metal_context *)backend->context;
3191+
struct ggml_backend_metal_context * metal_ctx = (struct ggml_backend_metal_context *)backend->context;
31923192

31933193
return ggml_metal_graph_compute(metal_ctx, cgraph);
31943194
}
31953195

31963196
GGML_CALL static bool ggml_backend_metal_supports_op(ggml_backend_t backend, const struct ggml_tensor * op) {
3197-
struct ggml_metal_context * metal_ctx = (struct ggml_metal_context *)backend->context;
3197+
struct ggml_backend_metal_context * metal_ctx = (struct ggml_backend_metal_context *)backend->context;
31983198

31993199
return ggml_metal_supports_op(metal_ctx, op);
32003200
}
@@ -3239,9 +3239,9 @@ static ggml_guid_t ggml_backend_metal_guid(void) {
32393239
}
32403240

32413241
ggml_backend_t ggml_backend_metal_init(void) {
3242-
struct ggml_metal_context * ctx = ggml_metal_init(GGML_DEFAULT_N_THREADS);
3243-
3242+
struct ggml_backend_metal_context * ctx = ggml_metal_init(GGML_DEFAULT_N_THREADS);
32443243
if (ctx == NULL) {
3244+
GGML_METAL_LOG_ERROR("%s: error: failed to allocate context\n", __func__);
32453245
return NULL;
32463246
}
32473247

@@ -3263,15 +3263,15 @@ bool ggml_backend_is_metal(ggml_backend_t backend) {
32633263
void ggml_backend_metal_set_n_cb(ggml_backend_t backend, int n_cb) {
32643264
GGML_ASSERT(ggml_backend_is_metal(backend));
32653265

3266-
struct ggml_metal_context * ctx = (struct ggml_metal_context *)backend->context;
3266+
struct ggml_backend_metal_context * ctx = (struct ggml_backend_metal_context *)backend->context;
32673267

32683268
ctx->n_cb = MIN(n_cb, GGML_METAL_MAX_BUFFERS);
32693269
}
32703270

32713271
void ggml_backend_metal_set_abort_callback(ggml_backend_t backend, ggml_abort_callback abort_callback, void * user_data) {
32723272
GGML_ASSERT(ggml_backend_is_metal(backend));
32733273

3274-
struct ggml_metal_context * ctx = (struct ggml_metal_context *)backend->context;
3274+
struct ggml_backend_metal_context * ctx = (struct ggml_backend_metal_context *)backend->context;
32753275

32763276
ctx->abort_callback = abort_callback;
32773277
ctx->abort_callback_data = user_data;
@@ -3280,15 +3280,15 @@ void ggml_backend_metal_set_abort_callback(ggml_backend_t backend, ggml_abort_ca
32803280
bool ggml_backend_metal_supports_family(ggml_backend_t backend, int family) {
32813281
GGML_ASSERT(ggml_backend_is_metal(backend));
32823282

3283-
struct ggml_metal_context * ctx = (struct ggml_metal_context *)backend->context;
3283+
struct ggml_backend_metal_context * ctx = (struct ggml_backend_metal_context *)backend->context;
32843284

32853285
return [ctx->device supportsFamily:(MTLGPUFamilyApple1 + family - 1)];
32863286
}
32873287

32883288
void ggml_backend_metal_capture_next_compute(ggml_backend_t backend) {
32893289
GGML_ASSERT(ggml_backend_is_metal(backend));
32903290

3291-
struct ggml_metal_context * ctx = (struct ggml_metal_context *)backend->context;
3291+
struct ggml_backend_metal_context * ctx = (struct ggml_backend_metal_context *)backend->context;
32923292
ctx->should_capture_next_compute = true;
32933293
}
32943294

0 commit comments

Comments
 (0)