Skip to content

Commit bcc7616

Browse files
committed
Fix build: forward-declare MultimodalInput in irunner.h
irunner is a header-only Buck target with no deps, so it cannot include multimodal_input.h (owned by multimodal_runner_lib which requires aten-variant deps). Use a forward declaration instead. Move the string convenience prefill(prompt, num_bos, num_eos) from IRunner to TextLLMRunner and MultimodalRunner, where multimodal_input.h is available for constructing MultimodalInput. This PR was authored with the assistance of Claude.
1 parent 37159cd commit bcc7616

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

extension/llm/runner/irunner.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
#include <string>
1717
#include <vector>
1818

19-
#include <executorch/extension/llm/runner/multimodal_input.h>
2019
#include <executorch/extension/llm/runner/stats.h>
2120
#include <executorch/runtime/core/error.h>
2221

2322
namespace executorch {
2423
namespace extension {
2524
namespace llm {
2625

26+
class MultimodalInput; // Forward declaration
27+
2728
// Configuration struct for generation parameters, fields should be sorted in
2829
// alphabetic order
2930
struct GenerationConfig {
@@ -146,16 +147,6 @@ class ET_EXPERIMENTAL IRunner {
146147
return runtime::Error::NotSupported;
147148
}
148149

149-
/**
150-
* Convenience overload: prefill a single text prompt.
151-
*/
152-
runtime::Error
153-
prefill(const std::string& prompt, int32_t num_bos = 0, int32_t num_eos = 0) {
154-
std::vector<MultimodalInput> inputs;
155-
inputs.emplace_back(MultimodalInput(prompt));
156-
return prefill(inputs, num_bos, num_eos);
157-
}
158-
159150
/**
160151
* Stop the generation process.
161152
*/

extension/llm/runner/multimodal_runner.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ class ET_EXPERIMENTAL MultimodalRunner : public IRunner {
138138
std::function<void(const std::string&)> token_callback = {},
139139
std::function<void(const Stats&)> stats_callback = {});
140140

141-
using IRunner::prefill; // Bring in string convenience overload
142-
143141
/**
144142
* Prefill multimodal inputs to fill the KV cache, for example to reload
145143
* chat history. Call generate() with a non-empty prompt afterwards to
@@ -155,6 +153,16 @@ class ET_EXPERIMENTAL MultimodalRunner : public IRunner {
155153
int32_t num_bos = 0,
156154
int32_t num_eos = 0) override;
157155

156+
/**
157+
* Convenience overload: prefill a single text prompt.
158+
*/
159+
::executorch::runtime::Error
160+
prefill(const std::string& prompt, int32_t num_bos = 0, int32_t num_eos = 0) {
161+
std::vector<MultimodalInput> inputs;
162+
inputs.emplace_back(MultimodalInput(prompt));
163+
return prefill(inputs, num_bos, num_eos);
164+
}
165+
158166
void stop() override {
159167
text_token_generator_->stop();
160168
}

extension/llm/runner/text_llm_runner.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <unordered_map>
1919

2020
#include <executorch/extension/llm/runner/irunner.h>
21+
#include <executorch/extension/llm/runner/multimodal_input.h>
2122
#include <executorch/extension/llm/runner/stats.h>
2223
#include <executorch/extension/llm/runner/text_decoder_runner.h>
2324
#include <executorch/extension/llm/runner/text_prefiller.h>
@@ -101,8 +102,6 @@ class ET_EXPERIMENTAL TextLLMRunner : public IRunner {
101102
std::function<void(const std::string&)> token_callback = {},
102103
std::function<void(const Stats&)> stats_callback = {}) override;
103104

104-
using IRunner::prefill; // Bring in string convenience overload
105-
106105
/**
107106
* Prefill multimodal inputs into the KV cache without generating.
108107
* Only text inputs are processed; non-text inputs are skipped.
@@ -116,6 +115,16 @@ class ET_EXPERIMENTAL TextLLMRunner : public IRunner {
116115
int32_t num_bos = 0,
117116
int32_t num_eos = 0) override;
118117

118+
/**
119+
* Convenience overload: prefill a single text prompt.
120+
*/
121+
::executorch::runtime::Error
122+
prefill(const std::string& prompt, int32_t num_bos = 0, int32_t num_eos = 0) {
123+
std::vector<MultimodalInput> inputs;
124+
inputs.emplace_back(MultimodalInput(prompt));
125+
return prefill(inputs, num_bos, num_eos);
126+
}
127+
119128
/**
120129
* Prefill a text prompt using GenerationConfig.
121130
* Deprecated: prefer prefill(prompt, num_bos, num_eos).

0 commit comments

Comments
 (0)