| 205 | config.dilation), |
| 206 | engine::core::TensorShape::from_dims({1, config.out_channels, output_shape.dims[2]}), |
| 207 | GGML_TYPE_F32); |
| 208 | output = output.valid() ? engine::modules::ConcatModule({0}).build(ctx, output, batch_output) : batch_output; |
| 209 | } |
| 210 | return add_bias_if_needed(ctx, output, config.out_channels, weights.bias); |
| 211 | } |
| 212 | |
| 213 | engine::core::TensorValue build_conv_transpose1d_col2im_test_path( |
| 214 | engine::core::ModuleBuildContext & ctx, |
| 215 | const engine::modules::ConvTranspose1dConfig & config, |
| 216 | const engine::core::TensorValue & input, |
| 217 | const engine::modules::ConvTranspose1dWeights & weights, |
| 218 | const engine::core::TensorShape & output_shape) { |
| 219 | auto * weight_perm = ggml_reshape_2d( |
| 220 | ctx.ggml, |
| 221 | ggml_cont(ctx.ggml, ggml_permute(ctx.ggml, weights.weight.tensor, 1, 2, 0, 3)), |
| 222 | config.in_channels, |
| 223 | config.kernel_size * config.out_channels); |
| 224 | ggml_tensor * bias_matrix = nullptr; |
| 225 | if (config.use_bias) { |
| 226 | if (!weights.bias.has_value()) { |
| 227 | throw std::runtime_error("test col2im path requires bias when use_bias is true"); |
| 228 | } |
| 229 | bias_matrix = ggml_reshape_2d(ctx.ggml, weights.bias->tensor, 1, config.out_channels); |
| 230 | } |
| 231 | engine::core::TensorValue output; |
| 232 | for (int64_t batch_index = 0; batch_index < input.shape.dims[0]; ++batch_index) { |
| 233 | auto * batch_input = ggml_view_2d( |
| 234 | ctx.ggml, |
| 235 | input.tensor, |
| 236 | input.tensor->ne[0], |
| 237 | input.tensor->ne[1], |
| 238 | input.tensor->nb[1], |
no test coverage detected