Skip to content

Commit 2f62b62

Browse files
more logs for failures at load (#17986)
Summary: Just more logs for when failures happen at load Differential Revision: D95627087
1 parent bb8a5df commit 2f62b62

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

runtime/executor/method.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,15 @@ Error Method::parse_values(const NamedDataMap* external_data_map) {
410410
const size_t n_value = flatbuffer_values->size();
411411
values_ = memory_manager_->method_allocator()->allocateList<EValue>(n_value);
412412
if (values_ == nullptr) {
413+
ET_LOG(Error, "Failed to allocate values array of size %zu", n_value);
413414
return Error::MemoryAllocationFailed;
414415
}
415416
const size_t n_input = inputs_size();
416417
if (n_input > 0) {
417418
input_set_ =
418419
memory_manager_->method_allocator()->allocateList<bool>(n_input);
419420
if (input_set_ == nullptr) {
421+
ET_LOG(Error, "Failed to allocate input_set array of size %zu", n_input);
420422
return Error::MemoryAllocationFailed;
421423
}
422424
for (size_t i = 0; i < n_input; ++i) {
@@ -440,6 +442,10 @@ Error Method::parse_values(const NamedDataMap* external_data_map) {
440442
memory_manager_->method_allocator()->allocateList<NamedData>(
441443
max_external_constants.get());
442444
if (external_constants_ == nullptr) {
445+
ET_LOG(
446+
Error,
447+
"Failed to allocate external_constants array of size %zu",
448+
max_external_constants.get());
443449
return Error::MemoryAllocationFailed;
444450
}
445451
Error err = parse_external_constants(external_data_map);
@@ -814,6 +820,7 @@ Result<Method> Method::load(
814820
memory_manager->method_allocator()
815821
->allocateInstance<PlatformMemoryAllocator>();
816822
if (platform_allocator == nullptr) {
823+
ET_LOG(Error, "Failed to allocate PlatformMemoryAllocator");
817824
return Error::MemoryAllocationFailed;
818825
}
819826
new (platform_allocator) PlatformMemoryAllocator();
@@ -863,6 +870,8 @@ Error Method::init(
863870
size_t n_delegate = delegates->size();
864871
delegates_ = method_allocator->allocateList<BackendDelegate>(n_delegate);
865872
if (delegates_ == nullptr) {
873+
ET_LOG(
874+
Error, "Failed to allocate delegates array of size %zu", n_delegate);
866875
return Error::MemoryAllocationFailed;
867876
}
868877

@@ -886,6 +895,7 @@ Error Method::init(
886895
merged_data_map_ =
887896
method_allocator->allocateInstance<internal::MergedDataMap>();
888897
if (merged_data_map_ == nullptr) {
898+
ET_LOG(Error, "Failed to allocate MergedDataMap");
889899
return Error::MemoryAllocationFailed;
890900
}
891901
new (merged_data_map_) internal::MergedDataMap(std::move(merged.get()));
@@ -938,6 +948,7 @@ Error Method::init(
938948
n_chains_ = chains->size();
939949
chains_ = method_allocator->allocateList<Chain>(n_chains_);
940950
if (chains_ == nullptr) {
951+
ET_LOG(Error, "Failed to allocate chains array of size %zu", n_chains_);
941952
return Error::MemoryAllocationFailed;
942953
}
943954

@@ -957,11 +968,15 @@ Error Method::init(
957968
auto chain_instruction_kernels =
958969
method_allocator->allocateList<OpFunction>(num_instructions);
959970
if (chain_instruction_kernels == nullptr) {
971+
ET_LOG(
972+
Error, "Failed to allocate instruction kernels for chain %zu", i);
960973
return Error::MemoryAllocationFailed;
961974
}
962975
auto chain_instruction_arg_lists =
963976
method_allocator->allocateList<InstructionArgs>(num_instructions);
964977
if (chain_instruction_arg_lists == nullptr) {
978+
ET_LOG(
979+
Error, "Failed to allocate instruction arg lists for chain %zu", i);
965980
return Error::MemoryAllocationFailed;
966981
}
967982

runtime/executor/program.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,19 @@ size_t Program::num_methods() const {
291291

292292
Result<const char*> Program::get_method_name(size_t plan_index) const {
293293
if (plan_index >= this->num_methods()) {
294+
ET_LOG(
295+
Error,
296+
"Plan index %zu >= num methods %zu",
297+
plan_index,
298+
this->num_methods());
294299
return Error::InvalidArgument;
295300
}
296301
auto internal_program =
297302
static_cast<const executorch_flatbuffer::Program*>(internal_program_);
298303
// We know that the execution plan exists because num_methods() returned > 0.
299304
auto name = internal_program->execution_plan()->Get(plan_index)->name();
300305
if (name == nullptr) {
306+
ET_LOG(Error, "Execution plan %zu has null name", plan_index);
301307
return Error::InvalidProgram;
302308
}
303309
return name->c_str();

runtime/executor/program_validation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ namespace runtime {
2222
ET_NODISCARD Error
2323
validate_tensor(const executorch_flatbuffer::Tensor* tensor) {
2424
if (tensor == nullptr) {
25+
ET_LOG(Error, "Tensor is null");
2526
return Error::InvalidProgram;
2627
}
2728

2829
const auto* sizes = tensor->sizes();
2930
if (sizes == nullptr) {
31+
ET_LOG(Error, "Tensor has null sizes");
3032
return Error::InvalidProgram;
3133
}
3234

@@ -82,6 +84,7 @@ validate_tensor(const executorch_flatbuffer::Tensor* tensor) {
8284
ET_NODISCARD Error
8385
validate_program(const executorch_flatbuffer::Program* program) {
8486
if (program == nullptr) {
87+
ET_LOG(Error, "Program is null");
8588
return Error::InvalidProgram;
8689
}
8790

schema/extended_header.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ uint64_t GetUInt64LE(const uint8_t* data) {
7070
const void* data,
7171
size_t size) {
7272
if (size < ExtendedHeader::kNumHeadBytes) {
73+
ET_LOG(
74+
Error,
75+
"Extended header data size %zu < minimum %zu",
76+
size,
77+
ExtendedHeader::kNumHeadBytes);
7378
return Error::InvalidArgument;
7479
}
7580
const uint8_t* header =

0 commit comments

Comments
 (0)