Skip to content

Commit e946379

Browse files
committed
llama : simplify returns if/else branches
1 parent 4ad0676 commit e946379

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

llama.cpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7380,12 +7380,8 @@ int llama_eval(
73807380
llama_kv_cache_tokens_rm(ctx->kv_self, n_past, -1);
73817381

73827382
const int ret = llama_decode_internal(*ctx, llama_batch_get_one(tokens, n_tokens, n_past, 0), n_threads);
7383-
if (ret != 0) {
7384-
if (ret < 0) {
7385-
LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);
7386-
}
7387-
7388-
return ret;
7383+
if (ret < 0) {
7384+
LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);
73897385
}
73907386

73917387
return ret;
@@ -7402,12 +7398,8 @@ int llama_eval_embd(
74027398
llama_batch batch = { n_tokens, nullptr, embd, nullptr, nullptr, nullptr, n_past, 1, 0, };
74037399

74047400
const int ret = llama_decode_internal(*ctx, batch, n_threads);
7405-
if (ret != 0) {
7406-
if (ret < 0) {
7407-
LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);
7408-
}
7409-
7410-
return ret;
7401+
if (ret < 0) {
7402+
LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);
74117403
}
74127404

74137405
return ret;
@@ -7460,12 +7452,8 @@ int llama_decode(
74607452
struct llama_batch batch,
74617453
int n_threads) {
74627454
const int ret = llama_decode_internal(*ctx, batch, n_threads);
7463-
if (ret != 0) {
7464-
if (ret < 0) {
7465-
LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);
7466-
}
7467-
7468-
return ret;
7455+
if (ret < 0) {
7456+
LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);
74697457
}
74707458

74717459
return ret;

0 commit comments

Comments
 (0)