ggml : fix possible underflow in ggml_nbytes
This commit is contained in:
parent
6c8d01a8bb
commit
538f60934a
1 changed files with 6 additions and 0 deletions
|
@ -1151,6 +1151,12 @@ int64_t ggml_nrows(const struct ggml_tensor * tensor) {
|
|||
}
|
||||
|
||||
size_t ggml_nbytes(const struct ggml_tensor * tensor) {
|
||||
for (int i = 0; i < GGML_MAX_DIMS; ++i) {
|
||||
if (tensor->ne[i] <= 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
size_t nbytes;
|
||||
const size_t blck_size = ggml_blck_size(tensor->type);
|
||||
if (blck_size == 1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue