Skip to content

Commit aa12620

Browse files
authored
Merge branch 'ggml-org:master' into PAD_REFLECT_1D_expriment
2 parents dd6789b + e00f3fd commit aa12620

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

ggml/src/ggml-cann/ggml-cann.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,6 @@ static bool ggml_cann_compute_forward(ggml_backend_cann_context& ctx,
17281728
ggml_cann_get_rows(ctx, dst);
17291729
break;
17301730
case GGML_OP_SET_ROWS:
1731-
std::cout << "lcg GGML_OP_SET_ROWS"<< std::endl;
17321731
ggml_cann_set_rows(ctx, dst);
17331732
break;
17341733
case GGML_OP_DUP:

ggml/src/ggml-metal/ggml-metal-device.m

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,19 @@ ggml_metal_pipeline_t ggml_metal_library_compile_pipeline(ggml_metal_library_t l
327327

328328
GGML_LOG_DEBUG("%s: compiling pipeline: base = '%s', name = '%s'\n", __func__, base, name);
329329

330-
id<MTLFunction> mtl_function = [lib->obj newFunctionWithName:base_func constantValues:(cv ? cv->obj : nil) error:&error];
330+
id<MTLFunction> mtl_function;
331+
if (!cv) {
332+
mtl_function = [lib->obj newFunctionWithName:base_func];
333+
} else {
334+
mtl_function = [lib->obj newFunctionWithName:base_func constantValues:cv->obj error:&error];
335+
}
331336
if (!mtl_function) {
332337
ggml_critical_section_end();
333338

334339
GGML_LOG_ERROR("%s: error: failed to compile pipeline: base = '%s', name = '%s'\n", __func__, base, name);
335-
GGML_LOG_ERROR("%s: error: %s\n", __func__, [[error description] UTF8String]);
340+
if (error) {
341+
GGML_LOG_ERROR("%s: error: %s\n", __func__, [[error description] UTF8String]);
342+
}
336343

337344
return nil;
338345
}
@@ -817,6 +824,7 @@ bool ggml_metal_device_supports_op(ggml_metal_device_t dev, const struct ggml_te
817824

818825
// if false, the Metal buffer data is allocated in private GPU memory and is not shared with the host
819826
bool is_shared;
827+
bool owned;
820828

821829
// multiple buffers are used only to avoid the maximum buffer size limitation when using mmap
822830
int n_buffers;
@@ -949,6 +957,7 @@ ggml_metal_buffer_t ggml_metal_buffer_init(ggml_metal_device_t dev, size_t size,
949957
if (shared) {
950958
res->all_data = ggml_metal_host_malloc(size_aligned);
951959
res->is_shared = true;
960+
res->owned = true;
952961
} else {
953962
// dummy, non-NULL value - we'll populate this after creating the Metal buffer below
954963
res->all_data = (void *) 0x000000400ULL;
@@ -1007,6 +1016,7 @@ ggml_metal_buffer_t ggml_metal_buffer_map(ggml_metal_device_t dev, void * ptr, s
10071016
res->all_size = size;
10081017

10091018
res->is_shared = true;
1019+
res->owned = false;
10101020

10111021
res->n_buffers = 0;
10121022

@@ -1100,7 +1110,7 @@ void ggml_metal_buffer_free(ggml_metal_buffer_t buf) {
11001110

11011111
ggml_metal_buffer_rset_free(buf);
11021112

1103-
if (buf->is_shared) {
1113+
if (buf->is_shared && buf->owned) {
11041114
#if TARGET_OS_OSX
11051115
vm_deallocate((vm_map_t)mach_task_self(), (vm_address_t)buf->all_data, buf->all_size);
11061116
#else

0 commit comments

Comments
 (0)