Skip to content

Commit 8f1d204

Browse files
committed
removed std::optional
1 parent 467cc0a commit 8f1d204

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎packages/react-native-executorch/common/runner/multimodal_prefiller.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

‎packages/react-native-executorch/common/runner/multimodal_prefiller.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class MultimodalPrefiller {
6262
std::vector<Types::AudioSlot> &audio_slots);
6363
::executorch::runtime::Error load();
6464
bool is_method_loaded();
65-
std::optional<int64_t> get_max_seq_len() const;
66-
std::optional<int64_t> get_max_context_len() const;
65+
int64_t get_max_seq_len() const;
66+
int64_t get_max_context_len() const;
6767
bool get_enable_dynamic_shape() const;
6868

6969
private:

0 commit comments

Comments
 (0)