ggml icon indicating copy to clipboard operation
ggml copied to clipboard

re-introduce `n_dims` field?

Open foldl opened this issue 1 year ago • 4 comments
trafficstars

n_dims field is now deleted from ggml_tensor, and ggml_n_dims() can be used to get it.

Now, if we create a single column matrix (n_dims = 2, shape = n x 1), ggml_n_dims() == 1 which is just the same as a vector.

Maybe n_dims can be re-introduced?

foldl avatar Jan 23 '24 09:01 foldl

If ne[0] == 1 and ne[1] == 2 (i.e. a single-column matrix), ggml_n_dims() will return 2 which is correct.

ggerganov avatar Jan 23 '24 11:01 ggerganov

Oh, my fault.

I mean ggml_new_tensor_2d(..., 2, 1), then ggml_n_dims() == 1.

foldl avatar Jan 23 '24 12:01 foldl

Yes, this is correct, but I don't think it will cause any problems. Is there a specific problem that you run into because of this?

ggerganov avatar Jan 23 '24 13:01 ggerganov

When loading a single-row matrix, n_dims mismatching occurs:

https://github.com/foldl/chatllm.cpp/blob/247be09f8247c972d5f77d6263a2d173b8dfab8d/chat.cpp#L394C11-L398C12

Special treatment is needed for single-row matrices, or generally, tensors with the last ne[]-s are 1.

foldl avatar Jan 24 '24 02:01 foldl