Skip to content

Commit

Permalink
whisper : reuse whisper_decode_with_state (ggerganov#1521)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov authored and iThalay committed Sep 23, 2024
1 parent 42cc673 commit 6cadb21
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3538,19 +3538,10 @@ int whisper_decode_with_state(struct whisper_context * ctx, struct whisper_state
int whisper_decode(struct whisper_context * ctx, const whisper_token * tokens, int n_tokens, int n_past, int n_threads) {
if (ctx->state == nullptr) {
WHISPER_LOG_ERROR("%s: ERROR state was not loaded.\n", __func__);
return false;
}

whisper_kv_cache_seq_rm(ctx->state->kv_self, 0, n_past, -1);

whisper_batch_prep_legacy(ctx->state->batch, tokens, n_tokens, n_past, 0);

if (!whisper_decode_internal(*ctx, *ctx->state, ctx->state->batch, n_threads, nullptr, nullptr)) {
WHISPER_LOG_ERROR("%s: failed to eval\n", __func__);
return 1;
return -1;
}

return 0;
return whisper_decode_with_state(ctx, ctx->state, tokens, n_tokens, n_past, n_threads);
}

int whisper_tokenize(struct whisper_context * ctx, const char * text, whisper_token * tokens, int n_max_tokens) {
Expand Down

0 comments on commit 6cadb21

Please sign in to comment.