mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-23 16:44:22 +08:00
[Sync] Update to latest code (#2679)
* [Sync] Update to latest code * Add new code files * Add new code files * update code * Try to fix build.sh * Try to fix build.sh * Update code * Update requirements.txt * Update code --------- Co-authored-by: Jiang-Jia-Jun <jiangjiajun@baidu.com>
This commit is contained in:
@@ -20,15 +20,6 @@ from pathlib import Path
|
||||
|
||||
from .model_base import ModelForCasualLM, ModelRegistry
|
||||
|
||||
inference_runner_supported_models = [
|
||||
"Ernie4_5_MoeForCausalLM",
|
||||
"Ernie4_5_MTPForCausalLM",
|
||||
"Qwen2ForCausalLM",
|
||||
"Qwen3MoeForCausalLM",
|
||||
"Ernie4_5_ForCausalLM",
|
||||
"Qwen3ForCausalLM",
|
||||
]
|
||||
|
||||
|
||||
def _find_py_files(root_dir):
|
||||
root_path = Path(root_dir)
|
||||
@@ -44,22 +35,23 @@ def _find_py_files(root_dir):
|
||||
return py_files
|
||||
|
||||
|
||||
def auto_models_registry():
|
||||
def auto_models_registry(dir_path,
|
||||
register_path="fastdeploy.model_executor.models",
|
||||
suffix=""):
|
||||
"""
|
||||
auto registry all models in this folder
|
||||
"""
|
||||
for module_file in _find_py_files(os.path.dirname(__file__)):
|
||||
for module_file in _find_py_files(dir_path):
|
||||
try:
|
||||
module = importlib.import_module(
|
||||
f'fastdeploy.model_executor.models.{module_file}')
|
||||
module = importlib.import_module(f'{register_path}.{module_file}')
|
||||
for attr_name in dir(module):
|
||||
attr = getattr(module, attr_name)
|
||||
if inspect.isclass(attr) and issubclass(
|
||||
attr,
|
||||
ModelForCasualLM) and attr is not ModelForCasualLM:
|
||||
ModelRegistry.register(attr)
|
||||
ModelRegistry.register(attr, suffix=suffix)
|
||||
except ImportError:
|
||||
raise ImportError(f"{module_file=} import error")
|
||||
|
||||
|
||||
auto_models_registry()
|
||||
auto_models_registry(os.path.dirname(__file__))
|
||||
|
Reference in New Issue
Block a user