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

Function ggml_reshape_4d

ggml.c:4579–4604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4577}
4578
4579struct ggml_tensor * ggml_reshape_4d(
4580 struct ggml_context * ctx,
4581 struct ggml_tensor * a,
4582 int64_t ne0,
4583 int64_t ne1,
4584 int64_t ne2,
4585 int64_t ne3) {
4586 GGML_ASSERT(ggml_is_contiguous(a));
4587 GGML_ASSERT(ggml_nelements(a) == ne0*ne1*ne2*ne3);
4588
4589 bool is_node = false;
4590
4591 if (a->grad) {
4592 is_node = true;
4593 }
4594
4595 const int64_t ne[4] = { ne0, ne1, ne2, ne3 };
4596 struct ggml_tensor * result = ggml_new_tensor_impl(ctx, a->type, 4, ne, a, 0);
4597 ggml_format_name(result, "%s (reshaped)", a->name);
4598
4599 result->op = GGML_OP_RESHAPE;
4600 result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
4601 result->src[0] = a;
4602
4603 return result;
4604}
4605
4606static struct ggml_tensor * ggml_view_impl(
4607 struct ggml_context * ctx,

Callers 7

ggml_conv_2dFunction · 0.70
ggml_graph_importFunction · 0.70
build_persimmonMethod · 0.70
forward_batchFunction · 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