Skip to content

Commit 4d7f9ca

Browse files
authored
Add test when there are no segments
Differential Revision: D78568839 Pull Request resolved: #12646
1 parent 91eca89 commit 4d7f9ca

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

runtime/executor/program.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,18 @@ Result<executorch_flatbuffer::ExecutionPlan*> get_execution_plan(
172172
// only offset, the constant segment is empty and does not need to be loaded.
173173
const auto* constant_segment = flatbuffer_program->constant_segment();
174174
if (constant_segment != nullptr && constant_segment->offsets() != nullptr &&
175-
constant_segment->offsets()->size() > 1) {
175+
constant_segment->offsets()->size() > 0) {
176+
if (constant_segment->offsets()->size() == 1) {
177+
// No constants; the constant segment is empty and does not
178+
// need to be loaded.
179+
return Program(
180+
loader,
181+
segment_base_offset,
182+
std::move(program_data.get()),
183+
flatbuffer_program,
184+
/*constant_segment_data=*/FreeableBuffer{},
185+
std::move(pte_data_map));
186+
}
176187
// The constant data is inside a separate segment.
177188
const auto* constant_buffer = flatbuffer_program->constant_buffer();
178189
ET_CHECK_OR_RETURN_ERROR(

0 commit comments

Comments
 (0)