ggml : add ggml_cont() + optimize ggml_cpy() for contiguous dst

This commit is contained in:
Georgi Gerganov 2023-04-10 22:40:28 +03:00
parent 9d634ef452
commit c3ac702e5e
No known key found for this signature in database
GPG key ID: 449E073F9DC10735
2 changed files with 252 additions and 8 deletions

6
ggml.h
View file

@ -236,6 +236,7 @@ enum ggml_op {
GGML_OP_SCALE,
GGML_OP_CPY,
GGML_OP_CONT,
GGML_OP_RESHAPE,
GGML_OP_VIEW,
GGML_OP_PERMUTE,
@ -525,6 +526,11 @@ struct ggml_tensor * ggml_cpy(
struct ggml_tensor * a,
struct ggml_tensor * b);
// make contiguous
struct ggml_tensor * ggml_cont(
struct ggml_context * ctx,
struct ggml_tensor * a);
// return view(a), b specifies the new shape
// TODO: when we start computing gradient, make a copy instead of view
struct ggml_tensor * ggml_reshape(