@@ -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
0 commit comments