Fixed alignment of value fields in `LLamaModelMetadataOverride`

This commit is contained in:
Martin Evans 2023-12-24 22:02:22 +00:00
parent 3fc0f34cbe
commit 2cded1b296
2 changed files with 11 additions and 5 deletions

View File

@ -269,7 +269,7 @@ namespace LLama.Abstractions
dest.FloatValue = _valueFloat;
break;
case LLamaModelKvOverrideType.LLAMA_KV_OVERRIDE_BOOL:
dest.BoolValue = _valueBool ? -1 : 0;
dest.BoolValue = _valueBool ? -1L : 0;
break;
default:
throw new ArgumentOutOfRangeException();

View File

@ -21,22 +21,28 @@ public unsafe struct LLamaModelMetadataOverride
public LLamaModelKvOverrideType Tag;
/// <summary>
/// Value, **must** only be used if Tag == LLAMA_KV_OVERRIDE_INT
/// Add 4 bytes of padding, to align the next fields to 8 bytes
/// </summary>
[FieldOffset(132)]
private readonly int PADDING;
/// <summary>
/// Value, **must** only be used if Tag == LLAMA_KV_OVERRIDE_INT
/// </summary>
[FieldOffset(136)]
public long IntValue;
/// <summary>
/// Value, **must** only be used if Tag == LLAMA_KV_OVERRIDE_FLOAT
/// </summary>
[FieldOffset(132)]
[FieldOffset(136)]
public double FloatValue;
/// <summary>
/// Value, **must** only be used if Tag == LLAMA_KV_OVERRIDE_BOOL
/// </summary>
[FieldOffset(132)]
public int BoolValue;
[FieldOffset(136)]
public long BoolValue;
}
/// <summary>