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

Function main

external/ggml/examples/simple/simple-backend.cpp:114–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114int main(void) {
115 ggml_time_init();
116
117 simple_model model;
118 init_model(model);
119
120 struct ggml_cgraph * gf = build_graph(model);
121
122 // perform computation
123 struct ggml_tensor * result = compute(model, gf);
124
125 // create a array to print result
126 std::vector<float> out_data(ggml_nelements(result));
127
128 // bring the data from the backend memory
129 ggml_backend_tensor_get(result, out_data.data(), 0, ggml_nbytes(result));
130
131 // expected result:
132 // [ 60.00 55.00 50.00 110.00
133 // 90.00 54.00 54.00 126.00
134 // 42.00 29.00 28.00 64.00 ]
135
136 printf("mul mat (%d x %d) (transposed result):\n[", (int) result->ne[0], (int) result->ne[1]);
137 for (int j = 0; j < result->ne[1] /* rows */; j++) {
138 if (j > 0) {
139 printf("\n");
140 }
141
142 for (int i = 0; i < result->ne[0] /* cols */; i++) {
143 printf(" %.2f", out_data[j * result->ne[0] + i]);
144 }
145 }
146 printf(" ]\n");
147
148 // release backend memory and free backend
149 ggml_backend_sched_free(model.sched);
150 ggml_backend_free(model.backend);
151 ggml_backend_free(model.cpu_backend);
152 return 0;
153}

Callers

nothing calls this directly

Calls 10

ggml_time_initFunction · 0.85
init_modelFunction · 0.85
ggml_nelementsFunction · 0.85
ggml_backend_tensor_getFunction · 0.85
ggml_nbytesFunction · 0.85
ggml_backend_sched_freeFunction · 0.85
ggml_backend_freeFunction · 0.85
build_graphFunction · 0.70
computeFunction · 0.70
dataMethod · 0.45

Tested by

no test coverage detected