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

Function set_tensor_row_major

examples/ggml_simple_inference.cpp:13–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11namespace {
12
13void set_tensor_row_major(struct ggml_tensor * tensor, const std::vector<float> & values) {
14 if (values.size() != ggml_nelements(tensor)) {
15 throw std::runtime_error("tensor data size mismatch");
16 }
17
18 for (int64_t i = 0; i < static_cast<int64_t>(values.size()); ++i) {
19 ggml_set_f32_1d(tensor, static_cast<int>(i), values[static_cast<size_t>(i)]);
20 }
21}
22
23std::vector<float> read_tensor(const struct ggml_tensor * tensor) {
24 std::vector<float> values(static_cast<size_t>(ggml_nelements(tensor)));

Callers 1

mainFunction · 0.85

Calls 3

ggml_nelementsFunction · 0.85
ggml_set_f32_1dFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected