MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_reshape_2d

Function ggml_reshape_2d

ggml.c:4528–4551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4526}
4527
4528struct ggml_tensor * ggml_reshape_2d(
4529 struct ggml_context * ctx,
4530 struct ggml_tensor * a,
4531 int64_t ne0,
4532 int64_t ne1) {
4533 GGML_ASSERT(ggml_is_contiguous(a));
4534 GGML_ASSERT(ggml_nelements(a) == ne0*ne1);
4535
4536 bool is_node = false;
4537
4538 if (a->grad) {
4539 is_node = true;
4540 }
4541
4542 const int64_t ne[2] = { ne0, ne1 };
4543 struct ggml_tensor * result = ggml_new_tensor_impl(ctx, a->type, 2, ne, a, 0);
4544 ggml_format_name(result, "%s (reshaped)", a->name);
4545
4546 result->op = GGML_OP_RESHAPE;
4547 result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
4548 result->src[0] = a;
4549
4550 return result;
4551}
4552
4553struct ggml_tensor * ggml_reshape_3d(
4554 struct ggml_context * ctx,

Callers 9

ggml_conv_1dFunction · 0.70
ggml_conv_2dFunction · 0.70
llm_build_kv_storeFunction · 0.70
forwardFunction · 0.50
forward_batchFunction · 0.50
forward_loraFunction · 0.50
clip_image_build_graphFunction · 0.50
llama_build_train_graphsFunction · 0.50

Calls 5

ggml_is_contiguousFunction · 0.70
ggml_nelementsFunction · 0.70
ggml_new_tensor_implFunction · 0.70
ggml_format_nameFunction · 0.70
ggml_dup_tensorFunction · 0.70

Tested by

no test coverage detected