mirror of
https://github.com/ollama/ollama.git
synced 2026-04-17 15:53:27 +02:00
This change adds a new MLX based runner which includes: * Method-based MLX bindings * Subprocess-based MLX runner (x/mlxrunner) * KV cache with tree management * A basic sampler The GLM4-MoE-Lite model has been ported to use the new bindings. --------- Co-authored-by: Michael Yang <git@mxy.ng>
24 lines
468 B
Go
24 lines
468 B
Go
//go:build mlx
|
|
|
|
package mlx
|
|
|
|
// #include "generated.h"
|
|
import "C"
|
|
import "math"
|
|
|
|
func GELUApprox(t *Array) *Array {
|
|
return t.Multiply(
|
|
FromValue[float32](0.5),
|
|
).Multiply(
|
|
t.Add(
|
|
t.Power(FromValue[float32](3.0)).Multiply(FromValue[float32](0.044715)),
|
|
).Multiply(
|
|
FromValue(float32(math.Sqrt(2 / math.Pi))),
|
|
).Tanh().Add(FromValue[float32](1.0)),
|
|
).AsType(t.DType())
|
|
}
|
|
|
|
func SILU(t *Array) *Array {
|
|
return t.Multiply(t.Sigmoid()).AsType(t.DType())
|
|
}
|