| 347 | } |
| 348 | |
| 349 | ggml_tensor * conv1d( |
| 350 | ggml_context * ctx, |
| 351 | ggml_tensor * x, |
| 352 | const Conv1dWeights & conv, |
| 353 | const std::string & name) { |
| 354 | ggml_tensor * weight = weight_3d(ctx, conv.weight, conv.kernel, conv.in_channels, conv.out_channels, name + ".weight"); |
| 355 | ggml_tensor * x3 = ggml_reshape_3d(ctx, contiguous_if_needed(ctx, x), x->ne[0], x->ne[1], 1); |
| 356 | ggml_tensor * y3 = ggml_conv_1d_fast_1d_im2col( |
| 357 | ctx, |
| 358 | weight, |
| 359 | x3, |
| 360 | static_cast<int>(conv.stride), |
| 361 | static_cast<int>(conv.padding), |
| 362 | static_cast<int>(conv.dilation)); |
| 363 | ggml_tensor * y = ggml_reshape_2d(ctx, y3, y3->ne[0], y3->ne[1]); |
| 364 | if (conv.use_bias) { |
| 365 | y = ggml_add(ctx, y, weight_2d(ctx, *conv.bias, 1, conv.out_channels, name + ".bias")); |
| 366 | } |
| 367 | return named(y, name.c_str()); |
| 368 | } |
| 369 | |
| 370 | ggml_tensor * conv_transpose1d( |
| 371 | ggml_context * ctx, |
no test coverage detected