Browse Source

Merge pull request #691 from martindevans/empty_batch_check

Empty batch check
pull/700/head
Martin Evans GitHub 2 years ago
parent
commit
e9fd7f96e0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      LLama/Native/SafeLLamaContextHandle.cs

+ 6
- 0
LLama/Native/SafeLLamaContextHandle.cs View File

@@ -368,6 +368,9 @@ namespace LLama.Native
/// </returns>
public DecodeResult Decode(LLamaBatch batch)
{
if (batch.TokenCount == 0)
return DecodeResult.Ok;

lock (GlobalInferenceLock)
using (batch.ToNativeBatch(out var nb))
return (DecodeResult)llama_decode(this, nb);
@@ -383,6 +386,9 @@ namespace LLama.Native
/// <returns>A tuple, containing the decode result and the number of tokens that have <b>not</b> been decoded yet.</returns>
internal (DecodeResult, int) Decode(List<LLamaToken> tokens, LLamaSeqId id, LLamaBatch batch, ref int n_past)
{
if (tokens.Count == 0)
return (DecodeResult.Ok, 0);

var batchSize = checked((int)BatchSize);

// Evaluate the prompt, in chunks smaller than the max batch size


Loading…
Cancel
Save