FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
llama-cpp-python/examples/low_level_api/quantize.py at main · pascalarthur/llama-cpp-python · GitHub
pascalarthur
/
llama-cpp-python
Public
forked from
abetlen/llama-cpp-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
llama-cpp-python
/
examples
/
low_level_api
/
quantize.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (27 loc) · 1.02 KB
Breadcrumbs
llama-cpp-python
/
examples
/
low_level_api
/
quantize.py
Copy path
File metadata and controls
31 lines (27 loc) · 1.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import
os
import
argparse
import
llama_cpp
def
main
(
args
):
fname_inp
=
args
.
fname_inp
.
encode
(
"utf-8"
)
fname_out
=
args
.
fname_out
.
encode
(
"utf-8"
)
if
not
os
.
path
.
exists
(
fname_inp
):
raise
RuntimeError
(
f"Input file does not exist (
{
fname_inp
}
)"
)
if
os
.
path
.
exists
(
fname_out
):
raise
RuntimeError
(
f"Output file already exists (
{
fname_out
}
)"
)
ftype
=
args
.
type
args
=
llama_cpp
.
llama_model_quantize_default_params
()
args
.
ftype
=
ftype
return_code
=
llama_cpp
.
llama_model_quantize
(
fname_inp
,
fname_out
,
args
)
if
return_code
!=
0
:
raise
RuntimeError
(
"Failed to quantize model"
)
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"fname_inp"
,
type
=
str
,
help
=
"Path to input model"
)
parser
.
add_argument
(
"fname_out"
,
type
=
str
,
help
=
"Path to output model"
)
parser
.
add_argument
(
"type"
,
type
=
int
,
help
=
"Type of quantization (2: q4_0, 3: q4_1), see llama_cpp.py for enum"
,
)
args
=
parser
.
parse_args
()
main
(
args
)
Back
|
FazBrowse Home
|
New Git URL