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
jerrrrry
infinilm
Commits
760b769e
Commit
760b769e
authored
May 15, 2025
by
PanZezhong
Browse files
fix xmake
parent
e435558f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
scripts/jiuge.py
scripts/jiuge.py
+36
-0
scripts/libinfinicore_infer.py
scripts/libinfinicore_infer.py
+1
-1
xmake.lua
xmake.lua
+1
-1
No files found.
scripts/jiuge.py
View file @
760b769e
from
ctypes
import
POINTER
,
c_uint
,
c_void_p
,
byref
from
ctypes
import
POINTER
,
c_uint
,
c_void_p
,
byref
import
sys
import
time
import
time
from
libinfinicore_infer
import
(
from
libinfinicore_infer
import
(
JiugeMeta
,
JiugeMeta
,
...
@@ -243,3 +244,38 @@ class JiugeForCauslLM:
...
@@ -243,3 +244,38 @@ class JiugeForCauslLM:
for
kv_cache
in
kv_caches
:
for
kv_cache
in
kv_caches
:
drop_kv_cache
(
self
.
model_instance
,
kv_cache
)
drop_kv_cache
(
self
.
model_instance
,
kv_cache
)
return
output_content
,
avg_time
return
output_content
,
avg_time
def
test
():
if
len
(
sys
.
argv
)
<
3
:
print
(
"Usage: python test_llama.py [--cpu | --nvidia| --cambricon | --ascend | --metax | --moore] <path/to/model_dir> [n_device]"
)
sys
.
exit
(
1
)
model_path
=
sys
.
argv
[
2
]
device_type
=
DeviceType
.
DEVICE_TYPE_CPU
if
sys
.
argv
[
1
]
==
"--cpu"
:
device_type
=
DeviceType
.
DEVICE_TYPE_CPU
elif
sys
.
argv
[
1
]
==
"--nvidia"
:
device_type
=
DeviceType
.
DEVICE_TYPE_NVIDIA
elif
sys
.
argv
[
1
]
==
"--cambricon"
:
device_type
=
DeviceType
.
DEVICE_TYPE_CAMBRICON
elif
sys
.
argv
[
1
]
==
"--ascend"
:
device_type
=
DeviceType
.
DEVICE_TYPE_ASCEND
elif
sys
.
argv
[
1
]
==
"--metax"
:
device_type
=
DeviceType
.
DEVICE_TYPE_METAX
elif
sys
.
argv
[
1
]
==
"--moore"
:
device_type
=
DeviceType
.
DEVICE_TYPE_MOORE
else
:
print
(
"Usage: python test_llama.py [--cpu | --nvidia| --cambricon | --ascend | --metax | --moore] <path/to/model_dir> [n_device]"
)
sys
.
exit
(
1
)
ndev
=
int
(
sys
.
argv
[
3
])
if
len
(
sys
.
argv
)
>
3
else
1
model
=
JiugeForCauslLM
(
model_path
,
device_type
,
ndev
)
model
.
generate
(
"<用户>讲个长故事<AI>"
,
500
)
if
__name__
==
"__main__"
:
test
()
scripts/libinfinicore_infer.py
View file @
760b769e
...
@@ -28,7 +28,7 @@ class DataType(ctypes.c_int):
...
@@ -28,7 +28,7 @@ class DataType(ctypes.c_int):
class
DeviceType
(
ctypes
.
c_int
):
class
DeviceType
(
ctypes
.
c_int
):
DEVICE_TYPE_CPU
=
0
DEVICE_TYPE_CPU
=
0
DEVICE_TYPE_
CUD
A
=
1
DEVICE_TYPE_
NVIDI
A
=
1
DEVICE_TYPE_CAMBRICON
=
2
DEVICE_TYPE_CAMBRICON
=
2
DEVICE_TYPE_ASCEND
=
3
DEVICE_TYPE_ASCEND
=
3
DEVICE_TYPE_METAX
=
4
DEVICE_TYPE_METAX
=
4
...
...
xmake.lua
View file @
760b769e
...
@@ -16,5 +16,5 @@ target("infinicore_infer")
...
@@ -16,5 +16,5 @@ target("infinicore_infer")
set_installdir
(
INFINI_ROOT
)
set_installdir
(
INFINI_ROOT
)
add_installfiles
(
"include/infinicore_infer.h"
,
{
prefixdir
=
"include"
})
add_installfiles
(
"include/infinicore_infer.h"
,
{
prefixdir
=
"include"
})
add_installfiles
(
"include/infinicore_infer/*.h"
,
{
prefixdir
=
"include/infinicore_infer"
})
add_installfiles
(
"include/infinicore_infer/
models/
*.h"
,
{
prefixdir
=
"include/infinicore_infer
/models
"
})
target_end
()
target_end
()
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