ggerganov / ggml

Tensor library for machine learning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using memcpy on tensor data when the tensor is not contiguous

audiovention opened this issue · comments

I see in some places in the codebase the implicit assumption that a tensor's memory is contiguous, without any checks/asserts.
For example "ggml_metal_set_tensor" (get_tensor as well) has:
memcpy((void *) ((uint8_t *) id_dst.contents + offs), t->data, ggml_nbytes(t));

I just want to confirm - this would produce wrong results if the tensor has non-identity strides right?

Yes that's correct. In some places the necessary checks / asserts are missing.