Browse Source

Added `Divide` to `KvAccessor`

tags/v0.10.0
Martin Evans 2 years ago
parent
commit
e9d9042576
2 changed files with 20 additions and 3 deletions
  1. +17
    -0
      LLama/Batched/Conversation.cs
  2. +3
    -3
      LLama/Native/SafeLLamaContextHandle.cs

+ 17
- 0
LLama/Batched/Conversation.cs View File

@@ -264,6 +264,23 @@ public sealed class Conversation
_conversation.Executor.Context.NativeHandle.KvCacheSequenceShift(_conversation.ConversationId, start, end, delta);
}
#endregion

#region divide
/// <summary>
/// Integer division of the positions by factor of `d > 1`.
/// If the KV cache is RoPEd, the KV data is updated accordingly.
/// </summary>
/// <param name="start">Start position (inclusive). If less than zero, it is clamped to zero.</param>
/// <param name="end">End position (exclusive). If less than zero, it is treated as "infinity".</param>
/// <param name="divisor">Amount to divide each position by.</param>
public void Divide(LLamaPos start, LLamaPos end, int divisor)
{
if (divisor <= 0)
throw new ArgumentOutOfRangeException(nameof(divisor));

_conversation.Executor.Context.NativeHandle.KvCacheSequenceDivide(_conversation.ConversationId, start, end, divisor);
}
#endregion
}

/// <summary>


+ 3
- 3
LLama/Native/SafeLLamaContextHandle.cs View File

@@ -375,9 +375,9 @@ namespace LLama.Native
}

/// <summary>
/// Integer division of the positions by factor of `d > 1`
/// If the KV cache is RoPEd, the KV data is updated accordingly
/// p0 &lt; 0 : [0, p1]
/// Integer division of the positions by factor of `d > 1`.
/// If the KV cache is RoPEd, the KV data is updated accordingly.<br />
/// p0 &lt; 0 : [0, p1]<br />
/// p1 &lt; 0 : [p0, inf)
/// </summary>
/// <param name="seq"></param>


Loading…
Cancel
Save