Commit 760b769e authored by PanZezhong's avatar PanZezhong
Browse files

fix xmake

parent e435558f
from ctypes import POINTER, c_uint, c_void_p, byref
import sys
import time
from libinfinicore_infer import (
JiugeMeta,
......@@ -243,3 +244,38 @@ class JiugeForCauslLM:
for kv_cache in kv_caches:
drop_kv_cache(self.model_instance, kv_cache)
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()
......@@ -28,7 +28,7 @@ class DataType(ctypes.c_int):
class DeviceType(ctypes.c_int):
DEVICE_TYPE_CPU = 0
DEVICE_TYPE_CUDA = 1
DEVICE_TYPE_NVIDIA = 1
DEVICE_TYPE_CAMBRICON = 2
DEVICE_TYPE_ASCEND = 3
DEVICE_TYPE_METAX = 4
......
......@@ -16,5 +16,5 @@ target("infinicore_infer")
set_installdir(INFINI_ROOT)
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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment