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

Function build_graph

external/ggml/tests/test-conv1d.cpp:140–171  ·  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 p0 = 1;
157 int d0 = 1;
158
159 // split conv1d in fundamental methods for test unit
160 struct ggml_tensor* im2col_0 = ggml_im2col(ctx0, model.a, model.b, s0, 0, p0, 0, d0, 0, false, GGML_TYPE_F16);
161 ggml_set_name(im2col_0, "im2col_res");
162 ggml_build_forward_expand(gf, im2col_0);
163
164 struct ggml_tensor* conv1d_res = ggml_conv_1d(ctx0, model.a, model.b, s0, p0, d0);
165 ggml_set_name(conv1d_res, "conv1d_res");
166 ggml_build_forward_expand(gf, conv1d_res);
167
168 // delete the temporally context used to build the graph
169 ggml_free(ctx0);
170 return gf;
171}
172
173struct ggml_cgraph* compute_graph(const test_model & model, ggml_gallocr_t allocr) {
174 struct ggml_cgraph * gf = build_graph(model);

Callers 2

compute_graphFunction · 0.70
mainFunction · 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_1dFunction · 0.85
ggml_freeFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected