quantize any fp16/fp32 model

- FROM /path/to/{safetensors,pytorch}
- FROM /path/to/fp{16,32}.bin
- FROM model:fp{16,32}
This commit is contained in:
Michael Yang
2024-04-12 13:55:12 -07:00
parent d091fe3c21
commit 9685c34509
12 changed files with 654 additions and 556 deletions

32
types/ordered/map.go Normal file
View File

@@ -0,0 +1,32 @@
package ordered
type Map[K comparable, V any] struct {
s []K
m map[K]V
}
func NewMap[K comparable, V any]() *Map[K, V] {
return &Map[K, V]{
s: make([]K, 0),
m: make(map[K]V),
}
}
type iter_Seq2[K, V any] func(func(K, V) bool)
func (m *Map[K, V]) Items() iter_Seq2[K, V] {
return func(yield func(K, V) bool) {
for _, k := range m.s {
if !yield(k, m.m[k]) {
return
}
}
}
}
func (m *Map[K, V]) Add(k K, v V) {
if _, ok := m.m[k]; !ok {
m.s = append(m.s, k)
m.m[k] = v
}
}