@@ -609,7 +609,7 @@ __STATIC_INLINE__ struct ggml_tensor* sd_pad(struct ggml_context* ctx,
609609 int p2,
610610 int p3) {
611611 if (sd_is_circular_padding_enabled ()) {
612- return ggml_pad_circular (ctx, a, 0 , p0, 0 , p1, 0 , p2, 0 , p3);
612+ return ggml_pad_ext_circular (ctx, a, 0 , p0, 0 , p1, 0 , p2, 0 , p3);
613613 }
614614 else {
615615 return ggml_pad (ctx, a, p0, p1, p2, p3);
@@ -627,7 +627,7 @@ __STATIC_INLINE__ struct ggml_tensor* sd_pad_ext(struct ggml_context* ctx,
627627 int lp3,
628628 int rp3) {
629629 if (sd_is_circular_padding_enabled ()) {
630- return ggml_pad_circular (ctx, a, lp0, rp0, lp1, rp1, lp2, rp2, lp3, rp3);
630+ return ggml_pad_ext_circular (ctx, a, lp0, rp0, lp1, rp1, lp2, rp2, lp3, rp3);
631631 }
632632 return ggml_pad_ext (ctx, a, lp0, rp0, lp1, rp1, lp2, rp2, lp3, rp3);
633633}
@@ -1035,22 +1035,21 @@ __STATIC_INLINE__ struct ggml_tensor* ggml_nn_conv_2d(struct ggml_context* ctx,
10351035 const bool use_circular = sd_is_circular_padding_enabled ();
10361036 LOG_DEBUG (" use circular conv %d" , use_circular ? 1 : 0 );
10371037 const bool is_depthwise = (w->ne [2 ] == 1 && x->ne [2 ] == w->ne [3 ]);
1038+
1039+ if (use_circular && (p0 != 0 || p1 != 0 )) {
1040+ x = ggml_pad_ext_circular (ctx, x, p0, p0, p1, p1, 0 , 0 , 0 , 0 );
1041+ p0 = 0 ;
1042+ p1 = 0 ;
1043+ }
1044+
10381045 if (direct) {
1039- if (use_circular) {
1040- if (is_depthwise) {
1041- x = ggml_conv_2d_dw_direct_circular (ctx, w, x, s0, s1, p0, p1, d0, d1);
1042- } else {
1043- x = ggml_conv_2d_direct_circular (ctx, w, x, s0, s1, p0, p1, d0, d1);
1044- }
1046+ if (is_depthwise) {
1047+ x = ggml_conv_2d_dw_direct (ctx, w, x, s0, s1, p0, p1, d0, d1);
10451048 } else {
10461049 x = ggml_conv_2d_direct (ctx, w, x, s0, s1, p0, p1, d0, d1);
10471050 }
10481051 } else {
1049- if (use_circular) {
1050- x = ggml_conv_2d_circular (ctx, w, x, s0, s1, p0, p1, d0, d1);
1051- } else {
1052- x = ggml_conv_2d (ctx, w, x, s0, s1, p0, p1, d0, d1);
1053- }
1052+ x = ggml_conv_2d (ctx, w, x, s0, s1, p0, p1, d0, d1);
10541053 }
10551054 if (scale != 1 .f ) {
10561055 x = ggml_scale (ctx, x, 1 .f / scale);
0 commit comments