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
d2ec2237
Commit
d2ec2237
authored
Mar 12, 2025
by
Michael Yang
Browse files
count all vision tensors
parent
033cec23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
12 deletions
+9
-12
fs/ggml/ggml.go
fs/ggml/ggml.go
+9
-12
No files found.
fs/ggml/ggml.go
View file @
d2ec2237
...
@@ -579,12 +579,16 @@ func (f GGML) GraphSize(context, batch uint64, kvCacheType string) (kv, partialO
...
@@ -579,12 +579,16 @@ func (f GGML) GraphSize(context, batch uint64, kvCacheType string) (kv, partialO
}
}
func
(
llm
GGML
)
VisionGraphSize
()
(
weights
,
graphSize
uint64
)
{
func
(
llm
GGML
)
VisionGraphSize
()
(
weights
,
graphSize
uint64
)
{
switch
llm
.
KV
()
.
Architecture
()
{
for
name
,
layer
:=
range
llm
.
Tensors
()
.
GroupLayers
()
{
case
"mllama"
:
if
strings
.
HasPrefix
(
name
,
"v."
)
{
for
_
,
layer
:=
range
llm
.
Tensors
()
.
GroupLayers
()[
"v"
]
{
for
_
,
tensor
:=
range
layer
{
weights
+=
layer
.
Size
()
weights
+=
tensor
.
Size
()
}
}
}
}
switch
llm
.
KV
()
.
Architecture
()
{
case
"mllama"
:
kv
:=
func
(
n
string
)
uint64
{
kv
:=
func
(
n
string
)
uint64
{
if
v
,
ok
:=
llm
.
KV
()[
"mllama.vision."
+
n
]
.
(
uint32
);
ok
{
if
v
,
ok
:=
llm
.
KV
()[
"mllama.vision."
+
n
]
.
(
uint32
);
ok
{
return
uint64
(
v
)
return
uint64
(
v
)
...
@@ -611,15 +615,8 @@ func (llm GGML) VisionGraphSize() (weights, graphSize uint64) {
...
@@ -611,15 +615,8 @@ func (llm GGML) VisionGraphSize() (weights, graphSize uint64) {
embeddingLength
*
numPatches
*
maxNumTiles
+
embeddingLength
*
numPatches
*
maxNumTiles
+
9
*
embeddingLength
*
numPaddedPatches
*
maxNumTiles
+
9
*
embeddingLength
*
numPaddedPatches
*
maxNumTiles
+
numPaddedPatches
*
maxNumTiles
*
numPaddedPatches
*
maxNumTiles
*
headCount
)
numPaddedPatches
*
maxNumTiles
*
numPaddedPatches
*
maxNumTiles
*
headCount
)
case
"gemma3"
:
for
name
,
layer
:=
range
llm
.
Tensors
()
.
GroupLayers
()
{
if
strings
.
HasPrefix
(
name
,
"v."
)
{
for
_
,
tensor
:=
range
layer
{
weights
+=
tensor
.
Size
()
}
}
}
}
}
return
weights
,
graphSize
return
weights
,
graphSize
}
}
...
...
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