@@ -945,6 +945,7 @@ static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
945
945
"CONV_TRANSPOSE_1D" ,
946
946
"IM2COL" ,
947
947
"IM2COL_BACK" ,
948
+ "CONV_2D" ,
948
949
"CONV_2D_DW" ,
949
950
"CONV_TRANSPOSE_2D" ,
950
951
"POOL_1D" ,
@@ -986,7 +987,7 @@ static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
986
987
"GLU" ,
987
988
};
988
989
989
- static_assert (GGML_OP_COUNT == 85 , "GGML_OP_COUNT != 85 " );
990
+ static_assert (GGML_OP_COUNT == 86 , "GGML_OP_COUNT != 86 " );
990
991
991
992
static const char * GGML_OP_SYMBOL [GGML_OP_COUNT ] = {
992
993
"none" ,
@@ -1044,6 +1045,7 @@ static const char * GGML_OP_SYMBOL[GGML_OP_COUNT] = {
1044
1045
"conv_transpose_1d(x)" ,
1045
1046
"im2col(x)" ,
1046
1047
"im2col_back(x)" ,
1048
+ "conv_2d(x)" ,
1047
1049
"conv_2d_dw(x)" ,
1048
1050
"conv_transpose_2d(x)" ,
1049
1051
"pool_1d(x)" ,
@@ -1085,7 +1087,7 @@ static const char * GGML_OP_SYMBOL[GGML_OP_COUNT] = {
1085
1087
"glu(x)" ,
1086
1088
};
1087
1089
1088
- static_assert (GGML_OP_COUNT == 85 , "GGML_OP_COUNT != 85 " );
1090
+ static_assert (GGML_OP_COUNT == 86 , "GGML_OP_COUNT != 86 " );
1089
1091
1090
1092
static_assert (GGML_OP_POOL_COUNT == 2 , "GGML_OP_POOL_COUNT != 2" );
1091
1093
@@ -4291,6 +4293,44 @@ struct ggml_tensor * ggml_conv_2d_dw_direct(
4291
4293
return result ;
4292
4294
}
4293
4295
4296
+ // ggml_conv_2d_direct
4297
+
4298
+ struct ggml_tensor * ggml_conv_2d_direct (
4299
+ struct ggml_context * ctx ,
4300
+ struct ggml_tensor * a , // convolution kernel [KW, KH, IC, OC]
4301
+ struct ggml_tensor * b , // input data [W, H, C, N]
4302
+ int s0 , // stride dimension 0
4303
+ int s1 , // stride dimension 1
4304
+ int p0 , // padding dimension 0
4305
+ int p1 , // padding dimension 1
4306
+ int d0 , // dilation dimension 0
4307
+ int d1 ) {// dilation dimension 1
4308
+
4309
+ GGML_ASSERT (a -> ne [2 ] == b -> ne [2 ]);
4310
+ //GGML_ASSERT(a->type == b->type);
4311
+
4312
+ int64_t ne [4 ];
4313
+ ne [0 ] = ggml_calc_conv_output_size (b -> ne [0 ], a -> ne [0 ], s0 , p0 , d0 );
4314
+ ne [1 ] = ggml_calc_conv_output_size (b -> ne [1 ], a -> ne [1 ], s1 , p1 , d1 );
4315
+ ne [2 ] = a -> ne [3 ];
4316
+ ne [3 ] = b -> ne [3 ];
4317
+
4318
+ struct ggml_tensor * result = ggml_new_tensor (ctx , b -> type , 4 , ne );
4319
+
4320
+ ggml_set_op_params_i32 (result , 0 , s0 );
4321
+ ggml_set_op_params_i32 (result , 1 , s1 );
4322
+ ggml_set_op_params_i32 (result , 2 , p0 );
4323
+ ggml_set_op_params_i32 (result , 3 , p1 );
4324
+ ggml_set_op_params_i32 (result , 4 , d0 );
4325
+ ggml_set_op_params_i32 (result , 5 , d1 );
4326
+
4327
+ result -> op = GGML_OP_CONV_2D ;
4328
+ result -> src [0 ] = a ;
4329
+ result -> src [1 ] = b ;
4330
+
4331
+ return result ;
4332
+ }
4333
+
4294
4334
// ggml_conv_transpose_2d_p0
4295
4335
4296
4336
static int64_t ggml_calc_conv_transpose_output_size (int64_t ins , int64_t ks , int s , int p ) {
0 commit comments