Skip to content

Commit 406c1a3

Browse files
smesoggerganov
authored andcommitted
vulkan: add dryrun support to sin and cos ops (ggml/947)
sin and cos failed test-backend-ops because they tried to dereference a context pointer that is null on dry runs. This commit prevents that segfault. Signed-off-by: Salvatore Mesoraca <[email protected]>
1 parent 9cb9260 commit 406c1a3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ggml/src/ggml-vulkan.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4616,7 +4616,7 @@ static void ggml_vk_sqr(ggml_backend_vk_context * ctx, vk_context& subctx, const
46164616
}, dryrun);
46174617
}
46184618

4619-
static void ggml_vk_sin(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, ggml_tensor * dst) {
4619+
static void ggml_vk_sin(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, ggml_tensor * dst, bool dryrun = false) {
46204620
const uint32_t src0_type_size = ggml_type_size(src0->type);
46214621
const uint32_t dst_type_size = ggml_type_size(dst->type);
46224622

@@ -4626,10 +4626,10 @@ static void ggml_vk_sin(ggml_backend_vk_context * ctx, vk_context& subctx, const
46264626
(uint32_t) dst->ne[0], (uint32_t) dst->ne[1], (uint32_t) dst->ne[2], (uint32_t) dst->ne[3], (uint32_t) dst->nb[0] / dst_type_size, (uint32_t) dst->nb[1] / dst_type_size, (uint32_t) dst->nb[2] / dst_type_size, (uint32_t) dst->nb[3] / dst_type_size,
46274627
0,
46284628
0.0f, 0.0f,
4629-
});
4629+
}, dryrun);
46304630
}
46314631

4632-
static void ggml_vk_cos(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, ggml_tensor * dst) {
4632+
static void ggml_vk_cos(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, ggml_tensor * dst, bool dryrun = false) {
46334633
const uint32_t src0_type_size = ggml_type_size(src0->type);
46344634
const uint32_t dst_type_size = ggml_type_size(dst->type);
46354635

@@ -4639,7 +4639,7 @@ static void ggml_vk_cos(ggml_backend_vk_context * ctx, vk_context& subctx, const
46394639
(uint32_t) dst->ne[0], (uint32_t) dst->ne[1], (uint32_t) dst->ne[2], (uint32_t) dst->ne[3], (uint32_t) dst->nb[0] / dst_type_size, (uint32_t) dst->nb[1] / dst_type_size, (uint32_t) dst->nb[2] / dst_type_size, (uint32_t) dst->nb[3] / dst_type_size,
46404640
0,
46414641
0.0f, 0.0f,
4642-
});
4642+
}, dryrun);
46434643
}
46444644

46454645
static void ggml_vk_clamp(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, ggml_tensor * dst, bool dryrun = false) {
@@ -5783,11 +5783,11 @@ static void ggml_vk_build_graph(ggml_backend_vk_context * ctx, ggml_tensor * nod
57835783

57845784
break;
57855785
case GGML_OP_SIN:
5786-
ggml_vk_sin(ctx, compute_ctx, src0, node);
5786+
ggml_vk_sin(ctx, compute_ctx, src0, node, dryrun);
57875787

57885788
break;
57895789
case GGML_OP_COS:
5790-
ggml_vk_cos(ctx, compute_ctx, src0, node);
5790+
ggml_vk_cos(ctx, compute_ctx, src0, node, dryrun);
57915791

57925792
break;
57935793
case GGML_OP_CLAMP:

0 commit comments

Comments
 (0)