Skip to content

Commit db6b353

Browse files
committed
release : v1.5.1
1 parent f5e5cf2 commit db6b353

File tree

9 files changed

+254
-303
lines changed

9 files changed

+254
-303
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ publish: publish-trigger
4242
\n\
4343
cd /path/to/whisper.cpp/bindings/ios\n\
4444
git commit\n\
45-
git tag 1.5.0\n\
45+
git tag 1.5.1\n\
4646
git push origin master --tags\n\
4747
"
4848

Sources/whisper/ggml-alloc.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,14 @@ static ggml_tallocr_t node_tallocr(ggml_gallocr_t galloc, struct ggml_tensor * n
446446
return galloc->hash_allocs[ggml_hash_find_or_insert(galloc->hash_set, node)];
447447
}
448448

449-
static void init_view(ggml_gallocr_t galloc, struct ggml_tensor * view) {
449+
static void init_view(ggml_gallocr_t galloc, struct ggml_tensor * view, bool update_backend) {
450450
ggml_tallocr_t alloc = node_tallocr(galloc, view);
451451

452452
//printf("init_view: %s from src %s\n", view->name, view->view_src->name);
453453
GGML_ASSERT(view->view_src != NULL && view->view_src->data != NULL);
454-
view->backend = view->view_src->backend;
454+
if (update_backend) {
455+
view->backend = view->view_src->backend;
456+
}
455457
view->buffer = view->view_src->buffer;
456458
view->data = (char *)view->view_src->data + view->view_offs;
457459

@@ -469,7 +471,7 @@ static void allocate_node(ggml_gallocr_t galloc, struct ggml_tensor * node) {
469471

470472
if (node->data == NULL) {
471473
if (ggml_is_view(node)) {
472-
init_view(galloc, node);
474+
init_view(galloc, node, true);
473475
} else {
474476
// see if we can reuse a parent's buffer (inplace)
475477
if (ggml_op_can_inplace(node->op)) {
@@ -499,15 +501,14 @@ static void allocate_node(ggml_gallocr_t galloc, struct ggml_tensor * node) {
499501
AT_PRINTF("reusing view parent %s (%s) for %s\n", parent->name, view_src->name, node->name);
500502
node->view_src = view_src;
501503
view_src_hn->n_views += 1;
502-
init_view(galloc, node);
504+
init_view(galloc, node, false);
503505
return;
504506
}
505-
}
506-
else {
507+
} else {
507508
AT_PRINTF("reusing parent %s for %s\n", parent->name, node->name);
508509
node->view_src = parent;
509510
p_hn->n_views += 1;
510-
init_view(galloc, node);
511+
init_view(galloc, node, false);
511512
return;
512513
}
513514
}
@@ -537,7 +538,7 @@ static void ggml_tallocr_alloc_graph_impl(ggml_gallocr_t galloc, struct ggml_cgr
537538
hash_get(galloc, view_src)->n_views += 1;
538539
if (node->buffer == NULL && node->data != NULL) {
539540
// view of a pre-allocated tensor, didn't call init_view() yet
540-
init_view(galloc, node);
541+
init_view(galloc, node, true);
541542
}
542543
}
543544

@@ -548,7 +549,7 @@ static void ggml_tallocr_alloc_graph_impl(ggml_gallocr_t galloc, struct ggml_cgr
548549
}
549550
hash_get(galloc, parent)->n_children += 1;
550551
if (ggml_is_view(parent) && parent->buffer == NULL && parent->data != NULL) {
551-
init_view(galloc, parent);
552+
init_view(galloc, parent, true);
552553
}
553554
}
554555
}
@@ -663,7 +664,7 @@ size_t ggml_gallocr_alloc_graph(ggml_gallocr_t galloc, ggml_tallocr_t talloc, st
663664
return max_size;
664665
}
665666

666-
void ggml_gallocr_alloc_graph_n(ggml_gallocr_t galloc, struct ggml_cgraph * graph, struct ggml_hash_set hash_set, ggml_tallocr_t * hash_node_alloct) {
667+
void ggml_gallocr_alloc_graph_n(ggml_gallocr_t galloc, struct ggml_cgraph * graph, struct ggml_hash_set hash_set, ggml_tallocr_t * hash_node_talloc) {
667668
const size_t hash_size = hash_set.size;
668669

669670
GGML_ASSERT(hash_size >= (size_t)(graph->n_nodes + graph->n_leafs));
@@ -686,7 +687,7 @@ void ggml_gallocr_alloc_graph_n(ggml_gallocr_t galloc, struct ggml_cgraph * grap
686687
// reset hash values
687688
memset(galloc->hash_values, 0, sizeof(struct hash_node) * hash_size);
688689

689-
galloc->hash_allocs = hash_node_alloct;
690+
galloc->hash_allocs = hash_node_talloc;
690691

691692
ggml_tallocr_alloc_graph_impl(galloc, graph);
692693

Sources/whisper/ggml-metal.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ void ggml_metal_free(struct ggml_metal_context * ctx);
5252
void * ggml_metal_host_malloc(size_t n);
5353
void ggml_metal_host_free (void * data);
5454

55+
// helper to check if the device supports a specific family
56+
// ideally, the user code should be doing these checks
57+
// ref: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
58+
bool ggml_metal_supports_family(struct ggml_metal_context * ctx, int family);
59+
5560
// set the number of command buffers to use
5661
void ggml_metal_set_n_cb(struct ggml_metal_context * ctx, int n_cb);
5762

@@ -100,6 +105,8 @@ GGML_API bool ggml_backend_is_metal(ggml_backend_t backend);
100105

101106
GGML_API void ggml_backend_metal_set_n_cb(ggml_backend_t backend, int n_cb);
102107

108+
GGML_API bool ggml_backend_metal_supports_family(ggml_backend_t backend, int family);
109+
103110
#ifdef __cplusplus
104111
}
105112
#endif

Sources/whisper/ggml-metal.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,10 @@ void ggml_metal_host_free(void * data) {
459459
free(data);
460460
}
461461

462+
bool ggml_metal_supports_family(struct ggml_metal_context * ctx, int family) {
463+
return [ctx->device supportsFamily:(MTLGPUFamilyApple1 + family - 1)];
464+
}
465+
462466
void ggml_metal_set_n_cb(struct ggml_metal_context * ctx, int n_cb) {
463467
ctx->n_cb = MIN(n_cb, GGML_METAL_MAX_BUFFERS);
464468
}
@@ -1072,7 +1076,7 @@ void ggml_metal_graph_compute(
10721076
GGML_ASSERT(ne00 == ne10);
10731077
GGML_ASSERT(ne03 == ne13);
10741078

1075-
const uint gqa = ne12/ne02;
1079+
const unsigned int gqa = ne12/ne02;
10761080

10771081
// find the break-even point where the matrix-matrix kernel becomes more efficient compared
10781082
// to the matrix-vector kernel
@@ -1751,3 +1755,9 @@ void ggml_backend_metal_set_n_cb(ggml_backend_t backend, int n_cb) {
17511755

17521756
ggml_metal_set_n_cb(ctx, n_cb);
17531757
}
1758+
1759+
bool ggml_backend_metal_supports_family(ggml_backend_t backend, int family) {
1760+
struct ggml_metal_context * ctx = (struct ggml_metal_context *)backend->context;
1761+
1762+
return ggml_metal_supports_family(ctx, family);
1763+
}

Sources/whisper/ggml-quants.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,12 @@ static float make_qkx2_quants(int n, int nmax, const float * restrict x, const f
13681368
float max = x[0];
13691369
float sum_w = weights[0];
13701370
float sum_x = sum_w * x[0];
1371+
#ifdef HAVE_BUGGY_APPLE_LINKER
1372+
// use 'volatile' to prevent unroll and work around a bug in Apple ld64 1015.7
1373+
for (volatile int i = 1; i < n; ++i) {
1374+
#else
13711375
for (int i = 1; i < n; ++i) {
1376+
#endif
13721377
if (x[i] < min) min = x[i];
13731378
if (x[i] > max) max = x[i];
13741379
float w = weights[i];

0 commit comments

Comments
 (0)