File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,16 @@ Error MultimodalRunner::load() {
62
62
ET_LOG (Info, format, __VA_ARGS__); \
63
63
}
64
64
65
+ Error MultimodalRunner::prefill (std::vector<MultimodalInput>& inputs) {
66
+ if (!is_loaded ()) {
67
+ ET_CHECK_OK_OR_RETURN_ERROR (load ());
68
+ }
69
+ for (auto & input : inputs) {
70
+ ET_UNWRAP (multimodal_prefiller_->prefill (input, pos_));
71
+ }
72
+ return Error::Ok;
73
+ }
74
+
65
75
Error MultimodalRunner::generate (
66
76
const std::vector<MultimodalInput>& inputs,
67
77
const GenerationConfig& config,
Original file line number Diff line number Diff line change @@ -119,6 +119,15 @@ class ET_EXPERIMENTAL MultimodalRunner {
119
119
std::function<void (const std::string&)> token_callback = {},
120
120
std::function<void (const Stats&)> stats_callback = {});
121
121
122
+ /* *
123
+ * Prefill multimodal inputs, for example to reload chat history.
124
+ * @param inputs A vector of MultimodalInput objects containing images and
125
+ * text.
126
+ * @return The error code. KV cache position is tracked internally in pos_.
127
+ */
128
+ virtual ::executorch::runtime::Error prefill (
129
+ std::vector<MultimodalInput>& inputs);
130
+
122
131
inline void stop () {
123
132
text_token_generator_->stop ();
124
133
}
You can’t perform that action at this time.
0 commit comments