mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-30 08:42:00 +00:00 
			
		
		
		
	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 <s.mesoraca16@gmail.com>
This commit is contained in:
		 Salvatore Mesoraca
					Salvatore Mesoraca
				
			
				
					committed by
					
						 Georgi Gerganov
						Georgi Gerganov
					
				
			
			
				
	
			
			
			 Georgi Gerganov
						Georgi Gerganov
					
				
			
						parent
						
							9cb9260861
						
					
				
				
					commit
					406c1a32a1
				
			| @@ -4616,7 +4616,7 @@ static void ggml_vk_sqr(ggml_backend_vk_context * ctx, vk_context& subctx, const | |||||||
|     }, dryrun); |     }, dryrun); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void ggml_vk_sin(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, ggml_tensor * dst) { | static void ggml_vk_sin(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, ggml_tensor * dst, bool dryrun = false) { | ||||||
|     const uint32_t src0_type_size = ggml_type_size(src0->type); |     const uint32_t src0_type_size = ggml_type_size(src0->type); | ||||||
|     const uint32_t dst_type_size = ggml_type_size(dst->type); |     const uint32_t dst_type_size = ggml_type_size(dst->type); | ||||||
|  |  | ||||||
| @@ -4626,10 +4626,10 @@ static void ggml_vk_sin(ggml_backend_vk_context * ctx, vk_context& subctx, const | |||||||
|         (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, |         (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, | ||||||
|         0, |         0, | ||||||
|         0.0f, 0.0f, |         0.0f, 0.0f, | ||||||
|     }); |     }, dryrun); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void ggml_vk_cos(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, ggml_tensor * dst) { | static void ggml_vk_cos(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, ggml_tensor * dst, bool dryrun = false) { | ||||||
|     const uint32_t src0_type_size = ggml_type_size(src0->type); |     const uint32_t src0_type_size = ggml_type_size(src0->type); | ||||||
|     const uint32_t dst_type_size = ggml_type_size(dst->type); |     const uint32_t dst_type_size = ggml_type_size(dst->type); | ||||||
|  |  | ||||||
| @@ -4639,7 +4639,7 @@ static void ggml_vk_cos(ggml_backend_vk_context * ctx, vk_context& subctx, const | |||||||
|         (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, |         (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, | ||||||
|         0, |         0, | ||||||
|         0.0f, 0.0f, |         0.0f, 0.0f, | ||||||
|     }); |     }, dryrun); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void ggml_vk_clamp(ggml_backend_vk_context * ctx, vk_context& subctx, const ggml_tensor * src0, ggml_tensor * dst, bool dryrun = false) { | 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 | |||||||
|  |  | ||||||
|         break; |         break; | ||||||
|     case GGML_OP_SIN: |     case GGML_OP_SIN: | ||||||
|         ggml_vk_sin(ctx, compute_ctx, src0, node); |         ggml_vk_sin(ctx, compute_ctx, src0, node, dryrun); | ||||||
|  |  | ||||||
|         break; |         break; | ||||||
|     case GGML_OP_COS: |     case GGML_OP_COS: | ||||||
|         ggml_vk_cos(ctx, compute_ctx, src0, node); |         ggml_vk_cos(ctx, compute_ctx, src0, node, dryrun); | ||||||
|  |  | ||||||
|         break; |         break; | ||||||
|     case GGML_OP_CLAMP: |     case GGML_OP_CLAMP: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user