@@ -33,18 +33,18 @@ MultimodalPrefiller::MultimodalPrefiller(
3333 tokenizer_ (&tokenizer), metadata_(metadata),
3434 image_encoder_(image_encoder), audio_encoder_(audio_encoder) {}
3535
36- std::optional< int64_t > MultimodalPrefiller::get_max_seq_len () const {
36+ int64_t MultimodalPrefiller::get_max_seq_len () const {
3737 auto r = module_->get (kMaxSeqLen );
3838 if (r.error () != ::executorch::runtime::Error::Ok) {
3939 return metadata_.at (kMaxSeqLen );
4040 }
4141 return r->toScalar ().to <int64_t >();
4242}
4343
44- std::optional< int64_t > MultimodalPrefiller::get_max_context_len () const {
44+ int64_t MultimodalPrefiller::get_max_context_len () const {
4545 auto r = module_->get (kMaxContextLen );
4646 if (r.error () != ::executorch::runtime::Error::Ok) {
47- return metadata_.at (kMaxContextLen );
47+ return metadata_.at (kMaxContextLen ) || get_max_seq_len () ;
4848 }
4949 return r->toScalar ().to <int64_t >();
5050}
@@ -291,8 +291,8 @@ MultimodalPrefiller::prefill(const std::vector<MultimodalInput> &inputs,
291291 // * get_max_context_len — total KV budget. Caps max context length for
292292 // multi-turn conversation.
293293 // ------------------------------------------------------------
294- int64_t max_seq_len = get_max_seq_len (). value_or (- 1 ) ;
295- int64_t max_context_len = get_max_context_len (). value_or (max_seq_len) ;
294+ int64_t max_seq_len = get_max_seq_len ();
295+ int64_t max_context_len = get_max_context_len ();
296296 bool enable_dynamic_shape = get_enable_dynamic_shape ();
297297 const int64_t prefill_total_cap =
298298 enable_dynamic_shape ? max_context_len : max_seq_len;
0 commit comments