| 876 | 0, |
| 877 | 1, |
| 878 | weights.quantizer.in_project.bias.has_value(), |
| 879 | }).build(ctx, hidden_bdt, weights.quantizer.in_project); |
| 880 | auto projected_btd = engine::modules::TransposeModule({{0, 2, 1, 3}, 3}).build(ctx, projected_bdt); |
| 881 | auto flat = engine::core::reshape_tensor( |
| 882 | ctx, |
| 883 | engine::core::ensure_backend_addressable_layout(ctx, projected_btd), |
| 884 | engine::core::TensorShape::from_dims({projected_btd.shape.dims[1], config.codebook_dim})); |
| 885 | auto normalized = build_l2_normalized_rows(ctx, flat); |
| 886 | auto logits = engine::modules::LinearModule({ |
| 887 | config.codebook_dim, |
| 888 | config.codebook_size, |
| 889 | false, |
| 890 | GGML_PREC_F32, |
| 891 | }).build(ctx, normalized, {weights.quantizer.codebook, std::nullopt}); |
| 892 | auto ids = engine::core::wrap_tensor( |
| 893 | ggml_argmax(ctx.ggml, engine::core::ensure_backend_addressable_layout(ctx, logits).tensor), |
| 894 | engine::core::TensorShape::from_dims({projected_btd.shape.dims[1]}), |
| 895 | GGML_TYPE_I32); |
| 896 | return engine::core::reshape_tensor( |
| 897 | ctx, |
| 898 | ids, |
| 899 | engine::core::TensorShape::from_dims({1, projected_btd.shape.dims[1]})); |
no test coverage detected