mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-25 05:48:47 +01:00
ggml : remove ggml_cpy_inplace and ggml_cont_inplace (ggml/693)
This commit is contained in:
parent
5362e43962
commit
f85a973aa1
30
ggml.c
30
ggml.c
@ -4311,13 +4311,13 @@ struct ggml_tensor * ggml_set_2d_inplace(
|
|||||||
static struct ggml_tensor * ggml_cpy_impl(
|
static struct ggml_tensor * ggml_cpy_impl(
|
||||||
struct ggml_context * ctx,
|
struct ggml_context * ctx,
|
||||||
struct ggml_tensor * a,
|
struct ggml_tensor * a,
|
||||||
struct ggml_tensor * b,
|
struct ggml_tensor * b) {
|
||||||
bool inplace) {
|
|
||||||
GGML_ASSERT(ggml_nelements(a) == ggml_nelements(b));
|
GGML_ASSERT(ggml_nelements(a) == ggml_nelements(b));
|
||||||
|
|
||||||
bool is_node = false;
|
bool is_node = false;
|
||||||
|
|
||||||
if (!inplace && (a->grad || b->grad)) {
|
if (a->grad || b->grad) {
|
||||||
|
// inplace is false and either one have a grad
|
||||||
is_node = true;
|
is_node = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4341,29 +4341,21 @@ struct ggml_tensor * ggml_cpy(
|
|||||||
struct ggml_context * ctx,
|
struct ggml_context * ctx,
|
||||||
struct ggml_tensor * a,
|
struct ggml_tensor * a,
|
||||||
struct ggml_tensor * b) {
|
struct ggml_tensor * b) {
|
||||||
return ggml_cpy_impl(ctx, a, b, false);
|
return ggml_cpy_impl(ctx, a, b);
|
||||||
}
|
|
||||||
|
|
||||||
struct ggml_tensor * ggml_cpy_inplace(
|
|
||||||
struct ggml_context * ctx,
|
|
||||||
struct ggml_tensor * a,
|
|
||||||
struct ggml_tensor * b) {
|
|
||||||
return ggml_cpy_impl(ctx, a, b, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ggml_cont
|
// ggml_cont
|
||||||
|
|
||||||
static struct ggml_tensor * ggml_cont_impl(
|
static struct ggml_tensor * ggml_cont_impl(
|
||||||
struct ggml_context * ctx,
|
struct ggml_context * ctx,
|
||||||
struct ggml_tensor * a,
|
struct ggml_tensor * a) {
|
||||||
bool inplace) {
|
|
||||||
bool is_node = false;
|
bool is_node = false;
|
||||||
|
|
||||||
if (!inplace && a->grad) {
|
if (a->grad) {
|
||||||
is_node = true;
|
is_node = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a);
|
struct ggml_tensor * result = ggml_dup_tensor(ctx, a);
|
||||||
ggml_format_name(result, "%s (cont)", a->name);
|
ggml_format_name(result, "%s (cont)", a->name);
|
||||||
|
|
||||||
result->op = GGML_OP_CONT;
|
result->op = GGML_OP_CONT;
|
||||||
@ -4376,13 +4368,7 @@ static struct ggml_tensor * ggml_cont_impl(
|
|||||||
struct ggml_tensor * ggml_cont(
|
struct ggml_tensor * ggml_cont(
|
||||||
struct ggml_context * ctx,
|
struct ggml_context * ctx,
|
||||||
struct ggml_tensor * a) {
|
struct ggml_tensor * a) {
|
||||||
return ggml_cont_impl(ctx, a, false);
|
return ggml_cont_impl(ctx, a);
|
||||||
}
|
|
||||||
|
|
||||||
struct ggml_tensor * ggml_cont_inplace(
|
|
||||||
struct ggml_context * ctx,
|
|
||||||
struct ggml_tensor * a) {
|
|
||||||
return ggml_cont_impl(ctx, a, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make contiguous, with new shape
|
// make contiguous, with new shape
|
||||||
|
11
ggml.h
11
ggml.h
@ -1163,22 +1163,11 @@ extern "C" {
|
|||||||
struct ggml_tensor * a,
|
struct ggml_tensor * a,
|
||||||
struct ggml_tensor * b);
|
struct ggml_tensor * b);
|
||||||
|
|
||||||
// a -> b, in-place, return view(b)
|
|
||||||
GGML_API struct ggml_tensor * ggml_cpy_inplace(
|
|
||||||
struct ggml_context * ctx,
|
|
||||||
struct ggml_tensor * a,
|
|
||||||
struct ggml_tensor * b);
|
|
||||||
|
|
||||||
// make contiguous
|
// make contiguous
|
||||||
GGML_API struct ggml_tensor * ggml_cont(
|
GGML_API struct ggml_tensor * ggml_cont(
|
||||||
struct ggml_context * ctx,
|
struct ggml_context * ctx,
|
||||||
struct ggml_tensor * a);
|
struct ggml_tensor * a);
|
||||||
|
|
||||||
// make contiguous, in-place
|
|
||||||
GGML_API struct ggml_tensor * ggml_cont_inplace(
|
|
||||||
struct ggml_context * ctx,
|
|
||||||
struct ggml_tensor * a);
|
|
||||||
|
|
||||||
// make contiguous, with new shape
|
// make contiguous, with new shape
|
||||||
GGML_API struct ggml_tensor * ggml_cont_1d(
|
GGML_API struct ggml_tensor * ggml_cont_1d(
|
||||||
struct ggml_context * ctx,
|
struct ggml_context * ctx,
|
||||||
|
Loading…
Reference in New Issue
Block a user