Revert "Merge pull request #4938 from ollama/mxyng/fix-byte-order"

This reverts commit f5f245cc15, reversing
changes made to 94d37fdcae.

this change broke gguf v2 which is incorrectly detected as big endian
This commit is contained in:
Michael Yang
2024-06-11 15:55:44 -07:00
parent 0f3cf1d42e
commit 7bdcd1da94
2 changed files with 9 additions and 19 deletions

View File

@@ -36,23 +36,10 @@ func (c *containerGGUF) Name() string {
}
func (c *containerGGUF) Decode(rs io.ReadSeeker) (model, error) {
var version [4]byte
if err := binary.Read(rs, c.ByteOrder, &version); err != nil {
if err := binary.Read(rs, c.ByteOrder, &c.Version); err != nil {
return nil, err
}
// if the lower 16 bits are 0, the byte order is probably wrong
if c.ByteOrder.Uint32(version[:])&1<<4 == 0 {
switch c.ByteOrder {
case binary.LittleEndian:
c.ByteOrder = binary.BigEndian
case binary.BigEndian:
c.ByteOrder = binary.LittleEndian
}
}
c.Version = c.ByteOrder.Uint32(version[:])
var err error
switch c.Version {
case 1: