Skip to content

Commit a848aad

Browse files
committed
whisper : avoid designated initializer
1 parent b29d361 commit a848aad

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/whisper.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,18 +4190,13 @@ struct whisper_timings * whisper_get_timings(struct whisper_context * ctx) {
41904190
if (ctx->state == nullptr) {
41914191
return nullptr;
41924192
}
4193-
const int32_t n_sample = std::max(1, ctx->state->n_sample);
4194-
const int32_t n_encode = std::max(1, ctx->state->n_encode);
4195-
const int32_t n_decode = std::max(1, ctx->state->n_decode);
4196-
const int32_t n_batchd = std::max(1, ctx->state->n_batchd);
4197-
const int32_t n_prompt = std::max(1, ctx->state->n_prompt);
4198-
return new whisper_timings {
4199-
.sample_ms = 1e-3f * ctx->state->t_sample_us / n_sample,
4200-
.encode_ms = 1e-3f * ctx->state->t_encode_us / n_encode,
4201-
.decode_ms = 1e-3f * ctx->state->t_decode_us / n_decode,
4202-
.batchd_ms = 1e-3f * ctx->state->t_batchd_us / n_batchd,
4203-
.prompt_ms = 1e-3f * ctx->state->t_prompt_us / n_prompt,
4204-
};
4193+
whisper_timings * timings = new whisper_timings;
4194+
timings->sample_ms = 1e-3f * ctx->state->t_sample_us / std::max(1, ctx->state->n_sample);
4195+
timings->encode_ms = 1e-3f * ctx->state->t_encode_us / std::max(1, ctx->state->n_encode);
4196+
timings->decode_ms = 1e-3f * ctx->state->t_decode_us / std::max(1, ctx->state->n_decode);
4197+
timings->batchd_ms = 1e-3f * ctx->state->t_batchd_us / std::max(1, ctx->state->n_batchd);
4198+
timings->prompt_ms = 1e-3f * ctx->state->t_prompt_us / std::max(1, ctx->state->n_prompt);
4199+
return timings;
42054200
}
42064201

42074202
void whisper_print_timings(struct whisper_context * ctx) {

0 commit comments

Comments
 (0)