fix: set n_dims of tensor storage to 1 when it's 0

This commit is contained in:
leejet 2024-05-14 23:06:52 +08:00
parent ce1bcc74a6
commit 1d2af5ca3f

View File

@ -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);