runtime: Float, Time

This commit is contained in:
xushiwei
2024-05-07 07:32:25 +08:00
parent 025cff9494
commit 0edeb5cfd0
3 changed files with 8 additions and 7 deletions

View File

@@ -25,9 +25,9 @@ func main() {
var prompt *c.Char = c.Str("Once upon a time")
var checkpointPath *c.Char = c.Str("stories15M.bin")
var tokenizerPath *c.Char = c.Str("tokenizer.bin")
var temperature, topp llama2.Float = 1.0, 0.9
var temperature, topp c.Float = 1.0, 0.9
var steps c.Int = 256
var rngSeed uint64 = uint64(llama2.Time(nil))
var rngSeed uint64 = uint64(c.Time(nil))
// build the Transformer via the model .bin file
var transformer llama2.Transformer

4
c/c.go
View File

@@ -28,6 +28,7 @@ type (
Char = int8
Int = C.int
Uint = C.uint
Float = float32
Pointer = unsafe.Pointer
FilePtr = unsafe.Pointer
)
@@ -76,3 +77,6 @@ func Fprintf(fp FilePtr, format *Char, __llgo_va_list ...any) Int
//go:linkname Qsort C.qsort
func Qsort(base Pointer, count, elem uintptr, compar func(a, b Pointer) Int)
//go:linkname Time C.time
func Time(*int32) int32

View File

@@ -27,15 +27,12 @@ const (
)
type (
Char = int8
Char = c.Char
Int = c.Int
Uint = c.Uint
Float = float32
Float = c.Float
)
//go:linkname Time C.time
func Time(*int32) int32
// -----------------------------------------------------------------------------
/*