@@ -484,6 +484,7 @@ struct vk_device_struct {
484
484
vk_pipeline pipeline_rwkv_wkv7_f32;
485
485
vk_pipeline pipeline_opt_step_adamw_f32;
486
486
vk_pipeline pipeline_conv2d_f32;
487
+ vk_pipeline pipeline_conv2d_f16_f32;
487
488
vk_pipeline pipeline_conv2d_dw_whcn_f32;
488
489
vk_pipeline pipeline_conv2d_dw_cwhn_f32;
489
490
@@ -3074,12 +3075,21 @@ static void ggml_vk_load_shaders(vk_device& device) {
3074
3075
device, device->pipeline_conv2d_f32, "conv2d_f32", conv2d_f32_len, conv2d_f32_data, "main", 3,
3075
3076
sizeof(vk_op_conv2d_push_constants), { conv2d_BS_K, conv2d_BS_NPQ, 1 },
3076
3077
{ conv2d_WG_SIZE, conv2d_BS_K, conv2d_BS_CRS, conv2d_BS_NPQ, conv2d_TS_K, use_collectives }, 1, true, true);
3078
+ ggml_vk_create_pipeline(
3079
+ device, device->pipeline_conv2d_f16_f32, "conv2d_f16_f32", conv2d_f16_f32_len, conv2d_f16_f32_data, "main", 3,
3080
+ sizeof(vk_op_conv2d_push_constants), { conv2d_BS_K, conv2d_BS_NPQ, 1 },
3081
+ { conv2d_WG_SIZE, conv2d_BS_K, conv2d_BS_CRS, conv2d_BS_NPQ, conv2d_TS_K, use_collectives }, 1, true, true);
3077
3082
} else {
3078
3083
ggml_vk_create_pipeline(
3079
3084
device, device->pipeline_conv2d_f32, "conv2d_f32", conv2d_f32_len, conv2d_f32_data, "main", 3,
3080
3085
sizeof(vk_op_conv2d_push_constants), { conv2d_BS_K, conv2d_BS_NPQ, 1 },
3081
3086
{ conv2d_WG_SIZE, conv2d_BS_K, conv2d_BS_CRS, conv2d_BS_NPQ, conv2d_TS_K, use_collectives }, 1, true,
3082
3087
false);
3088
+ ggml_vk_create_pipeline(
3089
+ device, device->pipeline_conv2d_f16_f32, "conv2d_f16_f32", conv2d_f16_f32_len, conv2d_f16_f32_data, "main", 3,
3090
+ sizeof(vk_op_conv2d_push_constants), { conv2d_BS_K, conv2d_BS_NPQ, 1 },
3091
+ { conv2d_WG_SIZE, conv2d_BS_K, conv2d_BS_CRS, conv2d_BS_NPQ, conv2d_TS_K, use_collectives }, 1, true,
3092
+ false);
3083
3093
}
3084
3094
3085
3095
ggml_vk_create_pipeline(device, device->pipeline_conv2d_dw_whcn_f32, "conv2d_dw_whcn_f32", conv2d_dw_whcn_f32_len, conv2d_dw_whcn_f32_data, "main", 3, sizeof(vk_op_conv2d_dw_push_constants), {512, 1, 1}, {}, 1);
@@ -6958,9 +6968,13 @@ static vk_pipeline ggml_vk_op_get_pipeline(ggml_backend_vk_context * ctx, const
6958
6968
}
6959
6969
return nullptr;
6960
6970
case GGML_OP_CONV_2D:
6961
- if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_F32 &&
6971
+ if (src1->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_F32 &&
6962
6972
ggml_is_contiguous(src0) && ggml_is_contiguous(src1) && ggml_is_contiguous(dst)) {
6963
- return ctx->device->pipeline_conv2d_f32;
6973
+ if (src0->type == GGML_TYPE_F32) {
6974
+ return ctx->device->pipeline_conv2d_f32;
6975
+ } else (src0->type == GGML_TYPE_F16) {
6976
+ return ctx->device->pipeline_conv2d_f16_f32;
6977
+ }
6964
6978
}
6965
6979
return nullptr;
6966
6980
case GGML_OP_CONV_2D_DW:
@@ -8178,13 +8192,13 @@ static void ggml_vk_pool_2d(ggml_backend_vk_context * ctx, vk_context& subctx, c
8178
8192
8179
8193
static void ggml_vk_conv_2d(ggml_backend_vk_context * ctx, vk_context & subctx, const ggml_tensor * src0,
8180
8194
const ggml_tensor * src1, ggml_tensor * dst, bool dryrun = false) {
8181
- GGML_ASSERT(src0->type == GGML_TYPE_F32);
8195
+ GGML_ASSERT(src0->type == GGML_TYPE_F32 || src0->type == GGML_TYPE_F16 );
8182
8196
GGML_ASSERT(src1->type == GGML_TYPE_F32);
8183
8197
GGML_ASSERT(dst->type == GGML_TYPE_F32);
8184
8198
8185
8199
GGML_TENSOR_BINARY_OP_LOCALS
8186
8200
8187
- GGML_ASSERT(nb00 == sizeof(float));
8201
+ GGML_ASSERT(nb00 == sizeof(float) || nb00 == sizeof(ggml_fp16_t) );
8188
8202
GGML_ASSERT(nb10 == sizeof(float));
8189
8203
GGML_ASSERT(nb0 == sizeof(float));
8190
8204
0 commit comments