@@ -173,7 +173,12 @@ VkResult allocate_tensor(
173173 .memoryTypeIndex = memory_index,
174174 };
175175
176- vkAllocateMemory (device, &allocate_info, nullptr , memory);
176+ result = vkAllocateMemory (device, &allocate_info, nullptr , memory);
177+ if (result != VK_SUCCESS) {
178+ ET_LOG (Error, " Failed to allocate tensor memory, error %d" , result);
179+ vkDestroyTensorARM (device, *tensor, nullptr );
180+ return result;
181+ }
177182
178183 // Bind tensor to memory
179184 const VkBindTensorMemoryInfoARM bind_info = {
@@ -183,7 +188,13 @@ VkResult allocate_tensor(
183188 .memory = *memory,
184189 .memoryOffset = 0 ,
185190 };
186- vkBindTensorMemoryARM (device, 1 , &bind_info);
191+ result = vkBindTensorMemoryARM (device, 1 , &bind_info);
192+ if (result != VK_SUCCESS) {
193+ ET_LOG (Error, " Failed to bind tensor memory, error %d" , result);
194+ vkDestroyTensorARM (device, *tensor, nullptr );
195+ vkFreeMemory (device, *memory, nullptr );
196+ return result;
197+ }
187198
188199 VkTensorViewCreateInfoARM tensor_view_info = {
189200 .sType = VK_STRUCTURE_TYPE_TENSOR_VIEW_CREATE_INFO_ARM,
@@ -799,7 +810,10 @@ bool VgfRepr::process_vgf(const char* vgf_data, ArrayRef<CompileSpec> specs) {
799810 .bindPoint = bind_point_requirement.bindPoint ,
800811 .objectIndex = 0 , // NOTE: tied to numObjects assert above
801812 };
802- VkMemoryRequirements2 memory_requirements;
813+ VkMemoryRequirements2 memory_requirements = {
814+ .sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
815+ .pNext = nullptr ,
816+ };
803817 vkGetDataGraphPipelineSessionMemoryRequirementsARM (
804818 vk_device, &memory_requirements_info, &memory_requirements);
805819
0 commit comments