Spaces:
Running
Running
whisper : reuse whisper_decode_with_state (#1521)
Browse files- whisper.cpp +2 -11
whisper.cpp
CHANGED
|
@@ -3538,19 +3538,10 @@ int whisper_decode_with_state(struct whisper_context * ctx, struct whisper_state
|
|
| 3538 |
int whisper_decode(struct whisper_context * ctx, const whisper_token * tokens, int n_tokens, int n_past, int n_threads) {
|
| 3539 |
if (ctx->state == nullptr) {
|
| 3540 |
WHISPER_LOG_ERROR("%s: ERROR state was not loaded.\n", __func__);
|
| 3541 |
-
return
|
| 3542 |
-
}
|
| 3543 |
-
|
| 3544 |
-
whisper_kv_cache_seq_rm(ctx->state->kv_self, 0, n_past, -1);
|
| 3545 |
-
|
| 3546 |
-
whisper_batch_prep_legacy(ctx->state->batch, tokens, n_tokens, n_past, 0);
|
| 3547 |
-
|
| 3548 |
-
if (!whisper_decode_internal(*ctx, *ctx->state, ctx->state->batch, n_threads, nullptr, nullptr)) {
|
| 3549 |
-
WHISPER_LOG_ERROR("%s: failed to eval\n", __func__);
|
| 3550 |
-
return 1;
|
| 3551 |
}
|
| 3552 |
|
| 3553 |
-
return
|
| 3554 |
}
|
| 3555 |
|
| 3556 |
int whisper_tokenize(struct whisper_context * ctx, const char * text, whisper_token * tokens, int n_max_tokens) {
|
|
|
|
| 3538 |
int whisper_decode(struct whisper_context * ctx, const whisper_token * tokens, int n_tokens, int n_past, int n_threads) {
|
| 3539 |
if (ctx->state == nullptr) {
|
| 3540 |
WHISPER_LOG_ERROR("%s: ERROR state was not loaded.\n", __func__);
|
| 3541 |
+
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3542 |
}
|
| 3543 |
|
| 3544 |
+
return whisper_decode_with_state(ctx, ctx->state, tokens, n_tokens, n_past, n_threads);
|
| 3545 |
}
|
| 3546 |
|
| 3547 |
int whisper_tokenize(struct whisper_context * ctx, const char * text, whisper_token * tokens, int n_max_tokens) {
|