summaryrefslogtreecommitdiff
path: root/llmc/header.go
blob: a154ae5385264ff85390140618b16e7a9eee034d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package llmc

import "encoding/binary"

const headerWords = 256

type Header struct {
	Magic   int32
	Version int32
	NumToks int32
}

func (h Header) encode() [headerWords * 4]byte {
	var buffer [headerWords * 4]byte

	binary.LittleEndian.PutUint32(buffer[0:], uint32(h.Magic))
	binary.LittleEndian.PutUint32(buffer[4:], uint32(h.Version))
	binary.LittleEndian.PutUint32(buffer[8:], uint32(h.NumToks))

	return buffer
}