modify style & little change

Former-commit-id: c988477d14dc656450d5fec31895781b7f9f7dce
This commit is contained in:
KUANGDD
2024-10-23 15:24:07 +08:00
parent 7d135bbdb8
commit d0889012c2
7 changed files with 45 additions and 25 deletions

View File

@@ -165,8 +165,17 @@ class HuggingfaceEngine(BaseEngine):
)
mm_inputs = template.mm_plugin.get_mm_inputs(**mm_input_dict, seqlens=[prompt_length], processor=processor)
for key, value in mm_inputs.items():
value = value if isinstance(value, torch.Tensor) else torch.tensor(value)
value = (
value
if isinstance(value, torch.Tensor)
else (
torch.stack(value)
if isinstance(value, list) and all(isinstance(v, torch.Tensor) for v in value)
else torch.tensor(value)
)
)
gen_kwargs[key] = value.to(model.device)
return gen_kwargs, prompt_length