File tree 5 files changed +26
-4
lines changed
5 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ Error Runner::load() {
99
99
" Failed to load %s as a Tiktoken artifact, trying BPE tokenizer" ,
100
100
tokenizer_path_.c_str ());
101
101
tokenizer_.reset ();
102
+ // @lint-ignore CLANGTIDY facebook-hte-Deprecated
102
103
tokenizer_ = std::make_unique<::tokenizers::Llama2cTokenizer>();
103
104
err = tokenizer_->load (tokenizer_path_);
104
105
ET_CHECK_TK_OK_OR_RETURN_ERROR (
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ namespace example {
18
18
class ET_EXPERIMENTAL LlavaImagePrefiller
19
19
: public ::executorch::extension::llm::ImagePrefiller {
20
20
public:
21
- LlavaImagePrefiller (::executorch::extension::Module* module)
21
+ explicit LlavaImagePrefiller (::executorch::extension::Module* module)
22
22
: ImagePrefiller(module){};
23
23
/* *
24
24
* Prefill an LLM Module with the given image input.
Original file line number Diff line number Diff line change 14
14
#include < executorch/extension/module/module.h>
15
15
#include < executorch/extension/tensor/tensor.h>
16
16
#include < executorch/runtime/platform/compiler.h>
17
- #include < functional>
18
17
19
18
namespace executorch {
20
19
namespace extension {
@@ -94,7 +93,13 @@ class ET_EXPERIMENTAL TextDecoderRunner {
94
93
}
95
94
96
95
protected:
97
- // TODO: use shared_ptr for module
96
+ /* *
97
+ * Note: TextDecoderRunner does not own the Module instance. It is expected
98
+ * that the outer class (likely Runner) manages the lifecycle of the Module.
99
+ * This means that the responsibility for creating, maintaining, and
100
+ * destroying the Module lies outside of TextDecoderRunner. Ensure that the
101
+ * Module remains valid for the duration of TextDecoderRunner's usage.
102
+ */
98
103
Module* module_;
99
104
bool use_kv_cache_;
100
105
bool should_stop_{false };
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ class ET_EXPERIMENTAL TextPrefiller {
24
24
bool use_kv_cache_,
25
25
bool enable_parallel_prefill,
26
26
int64_t max_seq_len = 128 );
27
+
28
+ virtual ~TextPrefiller () = default ;
27
29
/* *
28
30
* Prefill an LLM Module with the given text input.
29
31
* @param prompt_tokens The text prompt tokens to the LLM Module. Encoded by
@@ -32,7 +34,7 @@ class ET_EXPERIMENTAL TextPrefiller {
32
34
* Module.
33
35
* @return The next token of the LLM Module after prefill.
34
36
*/
35
- ::executorch::runtime::Result<uint64_t > prefill (
37
+ virtual ::executorch::runtime::Result<uint64_t > prefill (
36
38
std::vector<uint64_t >& prompt_tokens,
37
39
int64_t & start_pos);
38
40
@@ -48,6 +50,12 @@ class ET_EXPERIMENTAL TextPrefiller {
48
50
int64_t & start_pos);
49
51
50
52
private:
53
+ /* *
54
+ * Note: TextPrefiller does not own the TextDecoderRunner instance.
55
+ * The responsibility of managing the lifecycle of TextDecoderRunner
56
+ * lies with the outer class or entity (likely Runner) that creates
57
+ * and passes the TextDecoderRunner instance to TextPrefiller.
58
+ */
51
59
TextDecoderRunner* text_decoder_runner_;
52
60
bool use_kv_cache_;
53
61
bool enable_parallel_prefill_;
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ class ET_EXPERIMENTAL TextTokenGenerator {
32
32
use_kv_cache_(use_kv_cache),
33
33
stats_(stats) {}
34
34
35
+ virtual ~TextTokenGenerator () = default ;
36
+
35
37
/* *
36
38
* Token generation loop.
37
39
* @param tokens prompt tokens as well as the first token generated by
@@ -136,6 +138,12 @@ class ET_EXPERIMENTAL TextTokenGenerator {
136
138
}
137
139
138
140
private:
141
+ /* *
142
+ * Note: TextTokenGenerator does not own the tokenizer_ and
143
+ * text_decoder_runner_. The lifecycle of these objects should be managed
144
+ * externally, likely in the Runner. This class assumes that the provided
145
+ * pointers remain valid for the duration of its use.
146
+ */
139
147
::tokenizers::Tokenizer* tokenizer_;
140
148
TextDecoderRunner* text_decoder_runner_;
141
149
std::unique_ptr<std::unordered_set<uint64_t >> eos_ids_;
You can’t perform that action at this time.
0 commit comments