Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
a0dba0f8
You need to sign in or sign up before continuing.
Commit
a0dba0f8
authored
Apr 23, 2025
by
Michael Yang
Committed by
Michael Yang
Apr 25, 2025
Browse files
default slice values
parent
5e20b170
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
4 deletions
+63
-4
fs/ggml/ggml.go
fs/ggml/ggml.go
+4
-4
fs/ggml/ggml_test.go
fs/ggml/ggml_test.go
+59
-0
No files found.
fs/ggml/ggml.go
View file @
a0dba0f8
...
@@ -105,19 +105,19 @@ func (kv KV) Bool(key string, defaultValue ...bool) bool {
...
@@ -105,19 +105,19 @@ func (kv KV) Bool(key string, defaultValue ...bool) bool {
}
}
func
(
kv
KV
)
Strings
(
key
string
,
defaultValue
...
[]
string
)
[]
string
{
func
(
kv
KV
)
Strings
(
key
string
,
defaultValue
...
[]
string
)
[]
string
{
return
keyValue
(
kv
,
key
,
&
array
[
string
]{})
.
values
return
keyValue
(
kv
,
key
,
&
array
[
string
]{
values
:
append
(
defaultValue
,
[]
string
(
nil
))[
0
]
})
.
values
}
}
func
(
kv
KV
)
Ints
(
key
string
,
defaultValue
...
[]
int32
)
[]
int32
{
func
(
kv
KV
)
Ints
(
key
string
,
defaultValue
...
[]
int32
)
[]
int32
{
return
keyValue
(
kv
,
key
,
&
array
[
int32
]{})
.
values
return
keyValue
(
kv
,
key
,
&
array
[
int32
]{
values
:
append
(
defaultValue
,
[]
int32
(
nil
))[
0
]
})
.
values
}
}
func
(
kv
KV
)
Uints
(
key
string
,
defaultValue
...
[]
uint32
)
[]
uint32
{
func
(
kv
KV
)
Uints
(
key
string
,
defaultValue
...
[]
uint32
)
[]
uint32
{
return
keyValue
(
kv
,
key
,
&
array
[
uint32
]{})
.
values
return
keyValue
(
kv
,
key
,
&
array
[
uint32
]{
values
:
append
(
defaultValue
,
[]
uint32
(
nil
))[
0
]
})
.
values
}
}
func
(
kv
KV
)
Floats
(
key
string
,
defaultValue
...
[]
float32
)
[]
float32
{
func
(
kv
KV
)
Floats
(
key
string
,
defaultValue
...
[]
float32
)
[]
float32
{
return
keyValue
(
kv
,
key
,
&
array
[
float32
]{})
.
values
return
keyValue
(
kv
,
key
,
&
array
[
float32
]{
values
:
append
(
defaultValue
,
[]
float32
(
nil
))[
0
]
})
.
values
}
}
func
(
kv
KV
)
OllamaEngineRequired
()
bool
{
func
(
kv
KV
)
OllamaEngineRequired
()
bool
{
...
...
fs/ggml/ggml_test.go
View file @
a0dba0f8
...
@@ -2,6 +2,7 @@ package ggml
...
@@ -2,6 +2,7 @@ package ggml
import
(
import
(
"maps"
"maps"
"math"
"slices"
"slices"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -210,3 +211,61 @@ func TestTensorTypes(t *testing.T) {
...
@@ -210,3 +211,61 @@ func TestTensorTypes(t *testing.T) {
})
})
}
}
}
}
func
TestKeyValue
(
t
*
testing
.
T
)
{
kv
:=
KV
{
"general.architecture"
:
"test"
,
"test.strings"
:
&
array
[
string
]{
size
:
3
,
values
:
[]
string
{
"a"
,
"b"
,
"c"
}},
"test.float32s"
:
&
array
[
float32
]{
size
:
3
,
values
:
[]
float32
{
1.0
,
2.0
,
3.0
}},
"test.int32s"
:
&
array
[
int32
]{
size
:
3
,
values
:
[]
int32
{
1
,
2
,
3
}},
"test.uint32s"
:
&
array
[
uint32
]{
size
:
3
,
values
:
[]
uint32
{
1
,
2
,
3
}},
}
if
diff
:=
cmp
.
Diff
(
kv
.
Strings
(
"strings"
),
[]
string
{
"a"
,
"b"
,
"c"
});
diff
!=
""
{
t
.
Errorf
(
"unexpected strings (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Strings
(
"nonexistent.strings"
),
[]
string
(
nil
));
diff
!=
""
{
t
.
Errorf
(
"unexpected strings (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Strings
(
"default.strings"
,
[]
string
{
"ollama"
}),
[]
string
{
"ollama"
});
diff
!=
""
{
t
.
Errorf
(
"unexpected strings (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Floats
(
"float32s"
),
[]
float32
{
1.0
,
2.0
,
3.0
});
diff
!=
""
{
t
.
Errorf
(
"unexpected float32s (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Floats
(
"nonexistent.float32s"
),
[]
float32
(
nil
));
diff
!=
""
{
t
.
Errorf
(
"unexpected float32s (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Floats
(
"default.float32s"
,
[]
float32
{
math
.
MaxFloat32
}),
[]
float32
{
math
.
MaxFloat32
});
diff
!=
""
{
t
.
Errorf
(
"unexpected float32s (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Ints
(
"int32s"
),
[]
int32
{
1
,
2
,
3
});
diff
!=
""
{
t
.
Errorf
(
"unexpected int8s (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Ints
(
"nonexistent.int32s"
),
[]
int32
(
nil
));
diff
!=
""
{
t
.
Errorf
(
"unexpected int8s (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Ints
(
"default.int32s"
,
[]
int32
{
math
.
MaxInt32
}),
[]
int32
{
math
.
MaxInt32
});
diff
!=
""
{
t
.
Errorf
(
"unexpected int8s (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Uints
(
"uint32s"
),
[]
uint32
{
1
,
2
,
3
});
diff
!=
""
{
t
.
Errorf
(
"unexpected uint8s (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Uints
(
"nonexistent.uint32s"
),
[]
uint32
(
nil
));
diff
!=
""
{
t
.
Errorf
(
"unexpected uint8s (-got +want):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
kv
.
Uints
(
"default.uint32s"
,
[]
uint32
{
math
.
MaxUint32
}),
[]
uint32
{
math
.
MaxUint32
});
diff
!=
""
{
t
.
Errorf
(
"unexpected uint8s (-got +want):
\n
%s"
,
diff
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment