Skip to content

Commit

Permalink
Handle gguf zero-width types. (iree-org#15473)
Browse files Browse the repository at this point in the history
I don't know how these originate but this was encountered in a live
weights file and was causing and FPE upon parsing.
  • Loading branch information
stellaraccident authored Nov 8, 2023
1 parent 2fda954 commit 5b0fca4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions runtime/src/iree/io/formats/gguf/gguf_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ static uint64_t iree_io_gguf_calculate_storage_size(
element_count *= tensor_info->dimensions[i];
}
const ggml_type_traits_t type_traits = ggml_type_traits[tensor_info->type];
if (type_traits.type_size == 0) {
// For some reason some entries have a 0 type size and a 0 blck_size.
// Detect this to avoid FPE.
return 0;
}
return (element_count * type_traits.type_size) / type_traits.blck_size;
}

Expand Down

0 comments on commit 5b0fca4

Please sign in to comment.