Skip to content

Commit 1d2af5c

Browse files
committed
fix: set n_dims of tensor storage to 1 when it's 0
1 parent ce1bcc7 commit 1d2af5c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

model.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -888,10 +888,9 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
888888
}
889889
}
890890

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

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

0 commit comments

Comments
 (0)