Skip to content

Commit

Permalink
fix: set n_dims of tensor storage to 1 when it's 0
Browse files Browse the repository at this point in the history
  • Loading branch information
leejet committed May 14, 2024
1 parent ce1bcc7 commit 1d2af5c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,10 +888,9 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
}
}

// ggml/src/ggml.c:2745
if (n_dims < 1 || n_dims > GGML_MAX_DIMS) {
LOG_ERROR("skip tensor '%s' with n_dims %d", name.c_str(), n_dims);
continue;
// ggml_n_dims returns 1 for scalars
if (n_dims == 0) {
n_dims = 1;
}

TensorStorage tensor_storage(prefix + name, type, ne, n_dims, file_index, ST_HEADER_SIZE_LEN + header_size_ + begin);
Expand Down

0 comments on commit 1d2af5c

Please sign in to comment.