MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / run_step

Method run_step

src/models/qwen3_tts/talker.cpp:1247–1294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1245 }
1246 return best_token;
1247 }
1248 std::discrete_distribution<size_t> distribution(weights.begin(), weights.end());
1249 return indices[distribution(rng)];
1250}
1251
1252void apply_main_talker_processors(
1253 std::vector<float> & logits,
1254 const Qwen3TTSTalkerConfig & config,
1255 const std::vector<int32_t> & generated_first_codes,
1256 int64_t step,
1257 float repetition_penalty) {
1258 if (static_cast<int64_t>(logits.size()) != config.vocab_size) {
1259 throw std::runtime_error("Qwen3 talker logits size mismatch");
1260 }
1261 if (step < 2 && config.codec_eos_token_id >= 0 && config.codec_eos_token_id < config.vocab_size) {
1262 logits[static_cast<size_t>(config.codec_eos_token_id)] = -std::numeric_limits<float>::infinity();
1263 }
1264 const int64_t suppress_start = std::max<int64_t>(0, config.vocab_size - 1024);
1265 for (int64_t token = suppress_start; token < config.vocab_size; ++token) {
1266 if (token != config.codec_eos_token_id) {
1267 logits[static_cast<size_t>(token)] = -std::numeric_limits<float>::infinity();
1268 }
1269 }
1270 if (repetition_penalty == 1.0F) {
1271 return;
1272 }
1273 if (repetition_penalty <= 0.0F) {
1274 throw std::runtime_error("Qwen3 talker repetition penalty must be positive");
1275 }
1276 std::unordered_set<int32_t> seen_tokens;
1277 for (const int32_t token : generated_first_codes) {
1278 if (token < 0 || token >= config.vocab_size) {
1279 continue;
1280 }
1281 if (!seen_tokens.insert(token).second) {
1282 continue;
1283 }
1284 float & value = logits[static_cast<size_t>(token)];
1285 value = value < 0.0F ? value * repetition_penalty : value / repetition_penalty;
1286 }
1287}
1288
1289std::vector<float> frame_embedding(
1290 const Qwen3TalkerFrameCodes & frame,
1291 const std::vector<float> & text_hidden,
1292 const Qwen3TalkerWeights & weights,
1293 const Qwen3TTSTalkerConfig & config) {
1294 if (static_cast<int64_t>(frame.codes.size()) != config.num_code_groups) {
1295 throw std::runtime_error("Qwen3 talker frame code group count mismatch");
1296 }
1297 if (static_cast<int64_t>(text_hidden.size()) != config.hidden_size) {

Callers

nothing calls this directly

Calls 15

ggml_backend_tensor_setFunction · 0.85
ggml_fp32_to_fp16Function · 0.85
set_backend_threadsFunction · 0.85
compute_backend_graphFunction · 0.85
ggml_backend_synchronizeFunction · 0.85
ggml_backend_tensor_getFunction · 0.85
elapsed_msFunction · 0.50
sizeMethod · 0.45
valid_stepsMethod · 0.45
dataMethod · 0.45
current_endMethod · 0.45

Tested by

no test coverage detected