3232#include " litert/cc/litert_environment.h" // from @litert
3333#include " litert/cc/litert_macros.h" // from @litert
3434#include " runtime/components/model_resources.h"
35- #include " runtime/components/preprocessor/audio_preprocessor.h"
36- #include " runtime/components/preprocessor/audio_preprocessor_miniaudio.h"
37- #include " runtime/components/preprocessor/image_preprocessor.h"
38- #include " runtime/components/preprocessor/stb_image_preprocessor.h"
3935#include " runtime/core/session_factory.h"
4036#include " runtime/engine/engine.h"
4137#include " runtime/engine/engine_settings.h"
@@ -72,23 +68,19 @@ class EngineImpl : public Engine {
7268 explicit EngineImpl (EngineSettings engine_settings,
7369 std::unique_ptr<ModelResources> litert_model_resources,
7470 std::unique_ptr<Environment> lrt_env,
75- std::unique_ptr<ImagePreprocessor> image_preprocessor,
7671 std::unique_ptr<LlmExecutor> executor,
7772 std::unique_ptr<VisionExecutor> vision_executor,
78- std::unique_ptr<AudioPreprocessor> audio_preprocessor,
7973 std::unique_ptr<AudioExecutor> audio_executor,
8074 std::optional<BenchmarkInfo> benchmark_info,
8175 std::unique_ptr<ThreadPool> worker_thread_pool)
8276 : engine_settings_(std::move(engine_settings)),
8377 litert_model_resources_(std::move(litert_model_resources)),
8478 lrt_env_(std::move(lrt_env)),
85- image_preprocessor_(std::move(image_preprocessor)),
8679 executor_(std::move(executor)),
8780 vision_executor_(std::move(vision_executor)),
81+ audio_executor_(std::move(audio_executor)),
8882 stop_token_ids_(),
8983 sampler_params_(),
90- audio_preprocessor_(std::move(audio_preprocessor)),
91- audio_executor_(std::move(audio_executor)),
9284 benchmark_info_(std::move(benchmark_info)),
9385 worker_thread_pool_(std::move(worker_thread_pool)) {}
9486
@@ -103,9 +95,7 @@ class EngineImpl : public Engine {
10395 ABSL_CHECK (litert_model_resources_ != nullptr );
10496 ASSIGN_OR_RETURN (auto * tokenizer, litert_model_resources_->GetTokenizer ());
10597 return InitializeSession (executor_.get (), tokenizer,
106- /* image_preprocessor=*/ image_preprocessor_.get (),
10798 /* vision_executor=*/ vision_executor_.get (),
108- /* audio_preprocessor=*/ audio_preprocessor_.get (),
10999 /* audio_executor=*/ audio_executor_.get (), config,
110100 benchmark_info_, worker_thread_pool_.get ());
111101 }
@@ -124,20 +114,16 @@ class EngineImpl : public Engine {
124114 std::unique_ptr<ModelResources> litert_model_resources_;
125115 // LiteRT environment.
126116 std::unique_ptr<Environment> lrt_env_;
127- // Image preprocessor for the vision model.
128- std::unique_ptr<ImagePreprocessor> image_preprocessor_;
129117 // Shared executor for all sessions.
130118 std::unique_ptr<LlmExecutor> executor_;
131119 // Shared vision executor for all sessions.
132120 std::unique_ptr<VisionExecutor> vision_executor_;
121+ // shared audio executor for all sessions.
122+ std::unique_ptr<AudioExecutor> audio_executor_;
133123 // Default stop token ids for all sessions loaded from the model file.
134124 std::vector<std::vector<int >> stop_token_ids_;
135125 proto::SamplerParameters sampler_params_;
136126
137- // Shared audio preprocessor and executor for all sessions.
138- std::unique_ptr<AudioPreprocessor> audio_preprocessor_;
139- std::unique_ptr<AudioExecutor> audio_executor_;
140-
141127 // Benchmark info for the engine.
142128 std::optional<BenchmarkInfo> benchmark_info_;
143129
@@ -247,7 +233,6 @@ absl::StatusOr<std::unique_ptr<Engine>> Engine::CreateEngine(
247233 // TODO - b/436674053: Modularize the executor creation logic into a
248234 // separate executor class, and have unit test for it.
249235 std::unique_ptr<VisionExecutor> vision_executor;
250- std::unique_ptr<ImagePreprocessor> image_preprocessor;
251236 if (engine_settings.GetVisionExecutorSettings ().has_value ()) {
252237 ASSIGN_OR_RETURN (
253238 auto vision_executor_settings,
@@ -258,13 +243,9 @@ absl::StatusOr<std::unique_ptr<Engine>> Engine::CreateEngine(
258243 /* adapter_backend=*/ Backend::CPU));
259244 ASSIGN_OR_RETURN (vision_executor, VisionLiteRtCompiledModelExecutor::Create (
260245 vision_executor_settings, *lrt_env));
261- // Create the image preprocessor for processing the image input only if
262- // vision executor is enabled.
263- image_preprocessor = std::make_unique<StbImagePreprocessor>();
264246 }
265247
266248 std::unique_ptr<AudioExecutor> audio_executor;
267- std::unique_ptr<AudioPreprocessor> audio_preprocessor;
268249 if (engine_settings.GetAudioExecutorSettings ().has_value ()) {
269250 ASSIGN_OR_RETURN (
270251 auto audio_executor_settings,
@@ -274,9 +255,6 @@ absl::StatusOr<std::unique_ptr<Engine>> Engine::CreateEngine(
274255 engine_settings.GetAudioExecutorSettings ()->GetBackend ()));
275256 ASSIGN_OR_RETURN (audio_executor, AudioLiteRtCompiledModelExecutor::Create (
276257 audio_executor_settings, *lrt_env));
277- ASSIGN_OR_RETURN (audio_preprocessor,
278- AudioPreprocessorMiniAudio::Create (
279- AudioPreprocessorConfig::CreateDefaultUsmConfig ()));
280258 }
281259
282260 if (benchmark_info.has_value ()) {
@@ -290,8 +268,7 @@ absl::StatusOr<std::unique_ptr<Engine>> Engine::CreateEngine(
290268 /* max_num_threads=*/ 1 );
291269 auto llm_impl = std::make_unique<EngineImpl>(
292270 std::move (engine_settings), std::move (model_resources),
293- std::move (lrt_env), std::move (image_preprocessor), std::move (executor),
294- std::move (vision_executor), std::move (audio_preprocessor),
271+ std::move (lrt_env), std::move (executor), std::move (vision_executor),
295272 std::move (audio_executor), std::move (benchmark_info),
296273 std::move (worker_thread_pool));
297274
0 commit comments