in optimum/executorch/modeling.py [0:0]
def __init__(self, models: Dict[str, "ExecuTorchModule"], config: "PretrainedConfig"):
super().__init__(models, config)
if not hasattr(self, "model"):
raise AttributeError("Expected attribute 'model' not found in the instance.")
metadata = self.model.method_names()
logging.debug(f"Load all static methods: {metadata}")
if "use_kv_cache" in metadata:
self.use_kv_cache = self.model.run_method("use_kv_cache")[0]
if "get_max_seq_len" in metadata:
self.max_cache_size = self.model.run_method("get_max_seq_len")[0]
if "get_max_batch_size" in metadata:
self.max_batch_size = self.model.run_method("get_max_batch_size")[0]
if "get_dtype" in metadata:
self.dtype = self.model.run_method("get_dtype")[0]
if "get_bos_id" in metadata:
self.bos_token_id = self.model.run_method("get_bos_id")[0]
for key in ("get_eos_id", "get_eos_ids"):
if key in metadata:
self.eos_token_ids = self.model.run_method(key)
break
if "get_vocab_size" in metadata:
self.vocab_size = self.model.run_method("get_vocab_size")[0]
if "use_sdpa_with_kv_cache" in metadata:
self.use_sdpa_with_kv_cache = self.model.run_method("use_sdpa_with_kv_cache")[0]