@@ -91,8 +91,8 @@ void op_prof_report(const char * label, const OpProf & p) {
9191 break ;
9292 }
9393 const double pct = total_us > 0 ? (100.0 * p.us [o] / total_us) : 0.0 ;
94- log_msg (TRANSCRIBE_LOG_LEVEL_DEBUG , " [profile] %-20s %8.2f ms %5.1f%% x%lld" , ggml_op_name ( static_cast <ggml_op>(o)),
95- p.us [o] / 1000.0 , pct, static_cast <long long >(p.cnt [o]));
94+ log_msg (TRANSCRIBE_LOG_LEVEL_DEBUG , " [profile] %-20s %8.2f ms %5.1f%% x%lld" ,
95+ ggml_op_name ( static_cast <ggml_op>(o)), p.us [o] / 1000.0 , pct, static_cast <long long >(p.cnt [o]));
9696 }
9797}
9898
@@ -265,7 +265,7 @@ transcribe_status load(Loader & loader, const transcribe_model_load_params * par
265265 m->limits .model_max_ctx = m->hparams .dec_max_position_embeddings ;
266266 m->limits .prompt_overhead =
267267 static_cast <int >(m->hparams .prompt_prefix_tokens .size () + m->hparams .prompt_suffix_tokens .size ());
268- m->limits .gen_reserve = k_max_new;
268+ m->limits .gen_reserve = k_max_new;
269269 // audio_tokens ~= samples / (hop*2*merge) ; ms = tokens * hop*2*merge*1000/sr
270270 m->limits .ms_per_audio_token = static_cast <double >(m->hparams .fe_hop_length ) * 2.0 *
271271 m->hparams .audio_merge_size * 1000.0 / m->hparams .fe_sample_rate ;
@@ -306,8 +306,8 @@ transcribe_status load(Loader & loader, const transcribe_model_load_params * par
306306 }
307307
308308 gguf_init_params init_params{};
309- init_params.no_alloc = true ;
310- init_params.ctx = &m->ctx_meta ;
309+ init_params.no_alloc = true ;
310+ init_params.ctx = &m->ctx_meta ;
311311 gguf_context * gguf_data = gguf_init_from_file (loader.path ().c_str (), init_params);
312312 if (gguf_data == nullptr ) {
313313 return TRANSCRIBE_ERR_GGUF ;
@@ -435,11 +435,11 @@ transcribe_status encode_one(MossSession * cc,
435435 int & out_T_enc,
436436 int64_t & mel_us,
437437 int64_t & enc_us) {
438- const auto & hp = cm->hparams ;
439- const int n_mels = hp.enc_num_mel_bins ;
440- const int n_chunk = hp.fe_n_samples > 0 ? hp.fe_n_samples : 30 * hp.fe_sample_rate ;
441- const int d_model = hp.enc_d_model ;
442- const int merge = hp.audio_merge_size ;
438+ const auto & hp = cm->hparams ;
439+ const int n_mels = hp.enc_num_mel_bins ;
440+ const int n_chunk = hp.fe_n_samples > 0 ? hp.fe_n_samples : 30 * hp.fe_sample_rate ;
441+ const int d_model = hp.enc_d_model ;
442+ const int merge = hp.audio_merge_size ;
443443
444444 if (const transcribe_status st = ensure_sched (cc, cm); st != TRANSCRIBE_OK ) {
445445 return st;
@@ -449,8 +449,8 @@ transcribe_status encode_one(MossSession * cc,
449449 int T_trim_total = 0 ;
450450
451451 for (int start = 0 ; start < n_samples; start += n_chunk) {
452- const int real_len = std::min (n_chunk, n_samples - start);
453- const int token_len = audio_token_length (real_len, hp);
452+ const int real_len = std::min (n_chunk, n_samples - start);
453+ const int token_len = audio_token_length (real_len, hp);
454454 if (token_len <= 0 ) {
455455 log_msg (TRANSCRIBE_LOG_LEVEL_ERROR , " moss encode: degenerate token_len for chunk (real_len=%d)" , real_len);
456456 return TRANSCRIBE_ERR_GGUF ;
@@ -462,8 +462,8 @@ transcribe_status encode_one(MossSession * cc,
462462
463463 int nm = 0 , nf = 0 ;
464464 const int64_t t_mel0 = ggml_time_us ();
465- if (const transcribe_status mst = cm-> mel -> compute (chunk. data (), static_cast < size_t >(n_chunk), cc-> mel_buf , nm,
466- nf, cc->n_threads );
465+ if (const transcribe_status mst =
466+ cm-> mel -> compute (chunk. data (), static_cast < size_t >(n_chunk), cc-> mel_buf , nm, nf, cc->n_threads );
467467 mst != TRANSCRIBE_OK ) {
468468 log_msg (TRANSCRIBE_LOG_LEVEL_ERROR , " moss encode: mel compute failed (%s)" , transcribe_status_string (mst));
469469 return mst;
@@ -575,18 +575,18 @@ transcribe_status encode_one(MossSession * cc,
575575
576576// Build audio_dense [hidden, T_prompt] + keep_mask [1, T_prompt] host-side by
577577// scattering enc_out columns into the audio-pad prompt positions.
578- void build_injection (int hidden,
579- int T_prompt,
580- const std::vector<float > & enc_out,
578+ void build_injection (int hidden,
579+ int T_prompt,
580+ const std::vector<float > & enc_out,
581581 const std::vector<int32_t > & audio_positions,
582- std::vector<float > & audio_dense,
583- std::vector<float > & keep_mask) {
582+ std::vector<float > & audio_dense,
583+ std::vector<float > & keep_mask) {
584584 audio_dense.assign (static_cast <size_t >(hidden) * T_prompt, 0 .0f );
585585 keep_mask.assign (static_cast <size_t >(T_prompt), 1 .0f );
586586 for (size_t j = 0 ; j < audio_positions.size (); ++j) {
587587 const int pos = audio_positions[j];
588- std::memcpy (audio_dense.data () + static_cast <size_t >(pos) * hidden,
589- enc_out. data () + j * hidden, static_cast <size_t >(hidden) * sizeof (float ));
588+ std::memcpy (audio_dense.data () + static_cast <size_t >(pos) * hidden, enc_out. data () + j * hidden,
589+ static_cast <size_t >(hidden) * sizeof (float ));
590590 keep_mask[static_cast <size_t >(pos)] = 0 .0f ;
591591 }
592592}
@@ -705,8 +705,8 @@ transcribe_status run(transcribe_session * session,
705705 return st;
706706 }
707707 const bool slice_last = !dumps_on;
708- PrefillBuild pb = build_prefill_graph (cc->compute_ctx , cm->weights , cm->hparams , cc->kv_cache , T_prompt,
709- cc->decoder_use_flash , slice_last);
708+ PrefillBuild pb = build_prefill_graph (cc->compute_ctx , cm->weights , cm->hparams , cc->kv_cache , T_prompt,
709+ cc->decoder_use_flash , slice_last);
710710 if (pb.graph == nullptr || pb.out == nullptr ) {
711711 return TRANSCRIBE_ERR_GGUF ;
712712 }
@@ -747,8 +747,8 @@ transcribe_status run(transcribe_session * session,
747747 return TRANSCRIBE_ERR_GGUF ;
748748 }
749749 const int64_t t_prefill_us = perf_debug ? (ggml_time_us () - t_pf0) : 0 ;
750- cc->kv_cache .n = T_prompt;
751- cc->kv_cache .head = T_prompt;
750+ cc->kv_cache .n = T_prompt;
751+ cc->kv_cache .head = T_prompt;
752752
753753 if (dumps_on) {
754754 auto try_dump = [](const char * name, ggml_tensor * t, const char * stage) {
@@ -777,7 +777,7 @@ transcribe_status run(transcribe_session * session,
777777 generated_ids.push_back (next_tok);
778778
779779 // Step loop.
780- const int32_t eos_id = cm->hparams .eos_token_id ;
780+ const int32_t eos_id = cm->hparams .eos_token_id ;
781781 int cur_past = T_prompt;
782782 int max_n_kv = 1024 ;
783783 while (max_n_kv < T_prompt + gen_budget) {
@@ -790,8 +790,8 @@ transcribe_status run(transcribe_session * session,
790790 if (const transcribe_status st = reset_compute_ctx (cc, 8 ); st != TRANSCRIBE_OK ) {
791791 return st;
792792 }
793- StepBuild sb = build_step_graph (cc-> compute_ctx , cm-> weights , cm-> hparams , cc-> kv_cache , max_n_kv,
794- cc->decoder_use_flash );
793+ StepBuild sb =
794+ build_step_graph (cc-> compute_ctx , cm-> weights , cm-> hparams , cc-> kv_cache , max_n_kv, cc->decoder_use_flash );
795795 if (sb.graph == nullptr || sb.out == nullptr ) {
796796 return TRANSCRIBE_ERR_GGUF ;
797797 }
@@ -904,12 +904,13 @@ transcribe_status run(transcribe_session * session,
904904 };
905905 log_msg (TRANSCRIBE_LOG_LEVEL_DEBUG ,
906906 " [profile] step compute total=%.1f ms per-step mean=%.3f p50=%.3f p90=%.3f p99=%.3f max=%.3f ms" ,
907- t_step_compute_us / 1000.0 , (t_step_compute_us / 1000.0 ) / n_steps, pct (0.50 ), pct (0.90 ),
908- pct (0.99 ), sorted.back () / 1000.0 );
909- log_msg (TRANSCRIBE_LOG_LEVEL_DEBUG ,
910- " [profile] step overhead: input_set total=%.1f ms (%.3f/step) argmax_get total=%.1f ms (%.3f/step)" ,
911- t_step_input_us / 1000.0 , (t_step_input_us / 1000.0 ) / n_steps, t_step_get_us / 1000.0 ,
912- (t_step_get_us / 1000.0 ) / n_steps);
907+ t_step_compute_us / 1000.0 , (t_step_compute_us / 1000.0 ) / n_steps, pct (0.50 ), pct (0.90 ), pct (0.99 ),
908+ sorted.back () / 1000.0 );
909+ log_msg (
910+ TRANSCRIBE_LOG_LEVEL_DEBUG ,
911+ " [profile] step overhead: input_set total=%.1f ms (%.3f/step) argmax_get total=%.1f ms (%.3f/step)" ,
912+ t_step_input_us / 1000.0 , (t_step_input_us / 1000.0 ) / n_steps, t_step_get_us / 1000.0 ,
913+ (t_step_get_us / 1000.0 ) / n_steps);
913914 }
914915 op_prof_report (" ENCODE" , enc_prof);
915916 op_prof_report (" DECODE" , dec_prof);
@@ -939,10 +940,10 @@ transcribe_session::ResultSet finalize_utterance(MossModel * cm, std::vector<int
939940 generated_ids.pop_back ();
940941 }
941942 std::string raw_text = cm->tok .decode (generated_ids.data (), static_cast <int >(generated_ids.size ()));
942- rs.full_text = raw_text;
943- rs.result_kind = TRANSCRIBE_TIMESTAMPS_NONE ;
944- rs.has_result = true ;
945- rs.status = TRANSCRIBE_OK ;
943+ rs.full_text = raw_text;
944+ rs.result_kind = TRANSCRIBE_TIMESTAMPS_NONE ;
945+ rs.has_result = true ;
946+ rs.status = TRANSCRIBE_OK ;
946947 transcribe_session::SegmentEntry seg{};
947948 seg.text = raw_text;
948949 seg.t0_ms = 0 ;
@@ -960,8 +961,8 @@ transcribe_status run_batch_serial(MossSession * cc,
960961 if (cc->poll_abort ()) {
961962 return TRANSCRIBE_ERR_ABORTED ;
962963 }
963- const transcribe_status st = (pcm[i] == nullptr || n_samples[i] <= 0 ) ? TRANSCRIBE_ERR_INVALID_ARG
964- : run (cc, pcm[i], n_samples[i], params);
964+ const transcribe_status st = (pcm[i] == nullptr || n_samples[i] <= 0 ) ? TRANSCRIBE_ERR_INVALID_ARG :
965+ run (cc, pcm[i], n_samples[i], params);
965966 if (st == TRANSCRIBE_OK ) {
966967 cc->batch_results .push_back (cc->capture_result (st));
967968 } else {
@@ -1076,8 +1077,8 @@ transcribe_status run_batch(transcribe_session * session,
10761077 if (const transcribe_status st = reset_compute_ctx (cc, 32 ); st != TRANSCRIBE_OK ) {
10771078 return st;
10781079 }
1079- PrefillBuildBatched pb = build_prefill_graph_batched (cc-> compute_ctx , cm-> weights , cm-> hparams ,
1080- cc->kv_cache_batch , T_prompt_max, n, cc->decoder_use_flash );
1080+ PrefillBuildBatched pb = build_prefill_graph_batched (
1081+ cc-> compute_ctx , cm-> weights , cm-> hparams , cc->kv_cache_batch , T_prompt_max, n, cc->decoder_use_flash );
10811082 if (pb.graph == nullptr || pb.out == nullptr ) {
10821083 return TRANSCRIBE_ERR_GGUF ;
10831084 }
0 commit comments