| 269 | GGML_TYPE_F32); |
| 270 | } |
| 271 | |
| 272 | engine::core::TensorValue tokenizer_conv1d_bct( |
| 273 | engine::core::ModuleBuildContext & ctx, |
| 274 | const engine::core::TensorValue & input, |
| 275 | const S3TokenizerV2Weights::Conv1dWeights & weights) { |
| 276 | const int64_t batch = input.shape.dims[0]; |
| 277 | const int64_t in_frames = input.shape.dims[2]; |
| 278 | const int64_t out_frames = |
| 279 | (in_frames + 2 * weights.padding - weights.kernel) / weights.stride + 1; |
| 280 | auto output = engine::core::wrap_tensor( |
| 281 | ggml_conv_1d( |
| 282 | ctx.ggml, |
| 283 | contiguous(ctx, weights.weight_tensor).tensor, |
| 284 | contiguous(ctx, input).tensor, |
| 285 | static_cast<int>(weights.stride), |
| 286 | static_cast<int>(weights.padding), |
| 287 | 1), |
| 288 | engine::core::TensorShape::from_dims({batch, weights.out_channels, out_frames}), |
| 289 | GGML_TYPE_F32); |
| 290 | const auto bias_view = engine::core::reshape_tensor( |
| 291 | ctx, |
| 292 | weights.bias_tensor, |
| 293 | engine::core::TensorShape::from_dims({1, weights.out_channels, 1})); |
| 294 | return engine::core::wrap_tensor( |
| 295 | ggml_add(ctx.ggml, output.tensor, bias_view.tensor), |
| 296 | output.shape, |
| 297 | GGML_TYPE_F32); |
| 298 | } |
| 299 | |
| 300 | engine::core::TensorValue tokenizer_fsmn_btc( |
no test coverage detected