mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-12 00:37:04 +00:00
fix parsing big endian gguf
This commit is contained in:
15
llm/gguf.go
15
llm/gguf.go
@@ -36,10 +36,23 @@ func (c *containerGGUF) Name() string {
|
||||
}
|
||||
|
||||
func (c *containerGGUF) Decode(rs io.ReadSeeker) (model, error) {
|
||||
if err := binary.Read(rs, c.ByteOrder, &c.Version); err != nil {
|
||||
var version [4]byte
|
||||
if err := binary.Read(rs, c.ByteOrder, &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:
|
||||
|
||||
Reference in New Issue
Block a user