Skip to content

Commit

Permalink
hot-fix redundant import funasr (#12277)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgwhat authored Oct 25, 2024
1 parent a0c6432 commit 08cb065
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions python/llm/src/ipex_llm/transformers/npu_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def from_pretrained(cls, *args, **kwargs):
warnings.warn("`torch_dtype` will be ignored, `torch.float` will be used")
kwargs["torch_dtype"] = torch.float32

if hasattr(cls, "get_cls_model"):
cls.HF_Model = cls.get_cls_model()

low_bit = kwargs.pop("load_in_low_bit", "sym_int4")
qtype_map = {
"sym_int4": "sym_int4_rtn",
Expand Down Expand Up @@ -574,15 +577,19 @@ class AutoModelForTokenClassification(_BaseAutoModelClass):


class FunAsrAutoModel(_BaseAutoModelClass):
import funasr
HF_Model = funasr.AutoModel

def __init__(self, *args, **kwargs):
self.model = self.from_pretrained(*args, **kwargs)

def __getattr__(self, name):
return getattr(self.model, name)

@classmethod
def get_cls_model(cls):
import funasr
cls_model = funasr.AutoModel
return cls_model

@classmethod
def optimize_npu_model(cls, *args, **kwargs):
from ipex_llm.transformers.npu_models.convert_mp import optimize_funasr
Expand Down

0 comments on commit 08cb065

Please sign in to comment.