Skip to content

Commit dfc07e4

Browse files
remove error on unexpected file size
1 parent 1d3e60b commit dfc07e4

File tree

2 files changed

+0
-28
lines changed

2 files changed

+0
-28
lines changed

ggml/src/gguf.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -605,18 +605,6 @@ struct gguf_context * gguf_init_from_file_impl(std::istream & is, struct gguf_in
605605
}
606606
}
607607

608-
is.seekg(0, std::ifstream::end);
609-
const size_t file_size = is.tellg();
610-
is.seekg(ctx->offset, std::ifstream::beg);
611-
612-
const bool only_meta = file_size == ctx->offset;
613-
if (!only_meta && file_size != ctx->offset + ctx->size) {
614-
fprintf(stderr, "%s: GGUF file has size %zu but was expecting %zu (with tensor data) or %zu (without tensor data)\n",
615-
__func__, file_size, ctx->offset, ctx->offset + ctx->size);
616-
gguf_free(ctx);
617-
return nullptr;
618-
}
619-
620608
// load the tensor data only if requested
621609
if (params.ctx != nullptr) {
622610
// if the provided gguf_context is no_alloc, then we create "empty" tensors and do not read the binary blob

tests/test-gguf.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -726,22 +726,6 @@ static std::pair<int, int> test_handcrafted_file(const unsigned int seed) {
726726
ntest++;
727727
}
728728

729-
if (expect_context_not_null(hft)) {
730-
std::stringstream ss_eb = get_handcrafted_file(seed, hft, /*extra_bytes =*/ 1);
731-
struct gguf_context * gguf_ctx_eb = gguf_init_from_file_impl(ss_eb, gguf_params);
732-
733-
printf("%s: - context_null_with_extra_bytes: ", __func__);
734-
if (gguf_ctx_eb) {
735-
printf("\033[1;31mFAIL\033[0m\n");
736-
} else {
737-
printf("\033[1;32mOK\033[0m\n");
738-
npass++;
739-
}
740-
ntest++;
741-
742-
gguf_free(gguf_ctx_eb);
743-
}
744-
745729
const bool alignment_defined = hft == HANDCRAFTED_TENSORS_CUSTOM_ALIGN || hft == HANDCRAFTED_DATA_CUSTOM_ALIGN;
746730

747731
if (expect_context_not_null(hft)) {

0 commit comments

Comments
 (0)