MCPcopy Create free account
hub / github.com/pytorch/executorch / __init__

Method __init__

examples/models/llama/eval_llama_lib.py:95–116  ·  view source on GitHub ↗
(
        self,
        model: str,
        tokenizer: Union[SentencePieceTokenizer, Tiktoken],
        max_seq_length: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

93 """
94
95 def __init__(
96 self,
97 model: str,
98 tokenizer: Union[SentencePieceTokenizer, Tiktoken],
99 max_seq_length: Optional[int] = None,
100 ):
101 super().__init__(None, tokenizer, max_seq_length) # pyre-ignore
102 self._model = model # Expects model to be path to a .pte file
103
104 from executorch.extension.pybindings.portable_lib import _load_for_executorch
105
106 # Load custom ops and quantized ops.
107 from executorch.extension.pybindings import portable_lib # noqa # usort: skip
108
109 # Note: import this after portable_lib
110 from executorch.extension.llm.custom_ops import ( # noqa
111 custom_ops, # usort: skip
112 )
113 from executorch.kernels import quantized # noqa
114
115 self._et_model = _load_for_executorch(self._model)
116 self._use_kv_cache = self._et_model.run_method("use_kv_cache")[0] # pyre-ignore
117
118 def _model_call(self, inps):
119 # Given inps (tokens), return the logits from a single forward call

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 1

run_methodMethod · 0.80

Tested by

no test coverage detected