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

Function tensor_sum_elements

examples/benchmark/benchmark-matmult.cpp:34–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34static float tensor_sum_elements(const ggml_tensor * tensor) {
35 double sum = 0;
36 if (tensor->type == GGML_TYPE_F32) {
37 for (int j = 0; j < tensor->ne[1]; j++) {
38 for (int k = 0; k < tensor->ne[0]; k++) {
39 sum += ((float *) tensor->data)[j*tensor->ne[0] + k];
40 }
41 }
42 }
43 return sum;
44}
45
46static void tensor_dump(const ggml_tensor * tensor, const char * name) {
47 printf("%15s: type = %i (%5s) ne = %5" PRIi64 " x %5" PRIi64 " x %5" PRIi64 ", nb = (%5zi, %5zi, %5zi) - ", name,

Callers 2

tensor_dumpFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected