MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / build_graph

Function build_graph

external/ggml/tests/test-conv2d.cpp:140–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140struct ggml_cgraph * build_graph(const test_model& model) {
141 static size_t buf_size = ggml_tensor_overhead()*GGML_DEFAULT_GRAPH_SIZE + ggml_graph_overhead();
142 static std::vector<uint8_t> buf(buf_size);
143
144 struct ggml_init_params params0 = {
145 /*.mem_size =*/ buf_size,
146 /*.mem_buffer =*/ buf.data(),
147 /*.no_alloc =*/ true, // the tensors will be allocated later by ggml_gallocr_alloc_graph()
148 };
149
150 // create a temporally context to build the graph
151 struct ggml_context * ctx0 = ggml_init(params0);
152
153 struct ggml_cgraph * gf = ggml_new_graph(ctx0);
154
155 int s0 = 1;
156 int s1 = 1;
157 int p0 = 1;
158 int p1 = 1;
159 int d0 = 1;
160 int d1 = 1;
161
162 // split conv2d in fundamental methods for test unit
163 struct ggml_tensor* im2col_0 = ggml_im2col(ctx0, model.a, model.b, s0, s1, p0, p1, d0, d1, true, GGML_TYPE_F16);
164 ggml_set_name(im2col_0, "im2col_res");
165 ggml_build_forward_expand(gf, im2col_0);
166
167 // recalculate for avoid fragmentation
168 struct ggml_tensor* conv2d_res = ggml_conv_2d(ctx0, model.a, model.b, s0, s1, p0, p1, d0, d1);
169 ggml_set_name(conv2d_res, "conv2d_res");
170 ggml_build_forward_expand(gf, conv2d_res);
171
172 ggml_free(ctx0);
173 return gf;
174}
175
176struct ggml_cgraph * compute_graph(const test_model & model, ggml_gallocr_t allocr) {
177 struct ggml_cgraph * gf = build_graph(model);

Callers 7

compute_graphFunction · 0.70
mainFunction · 0.70
evalMethod · 0.70
eval_perfMethod · 0.70
eval_supportMethod · 0.70
eval_gradMethod · 0.70
build_graphMethod · 0.70

Calls 10

ggml_tensor_overheadFunction · 0.85
ggml_graph_overheadFunction · 0.85
ggml_initFunction · 0.85
ggml_new_graphFunction · 0.85
ggml_im2colFunction · 0.85
ggml_set_nameFunction · 0.85
ggml_conv_2dFunction · 0.85
ggml_freeFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected