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

Method write_tensor_data

external/ggml/src/gguf.cpp:1407–1424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1405 buf.push_back(val);
1406 written_bytes++;
1407 }
1408
1409 void write(const std::vector<int8_t> & val) override {
1410 buf.insert(buf.end(), val.begin(), val.end());
1411 written_bytes += val.size();
1412 }
1413
1414 void write_tensor_data(const struct gguf_tensor_info & info, const size_t offset_data, const size_t alignment) override {
1415 GGML_ASSERT(buf.size() - offset_data == info.offset);
1416
1417 GGML_ASSERT(ggml_is_contiguous(&info.t));
1418 const size_t offset = buf.size();
1419 const size_t nbytes = ggml_nbytes(&info.t);
1420
1421 buf.resize(offset + nbytes);
1422 if (info.t.buffer) {
1423 ggml_backend_tensor_get(&info.t, buf.data() + offset, 0, nbytes);
1424 } else {
1425 GGML_ASSERT(info.t.data);
1426 memcpy(buf.data() + offset, info.t.data, nbytes);
1427 }

Callers 1

gguf_write_outFunction · 0.45

Calls 6

ggml_is_contiguousFunction · 0.85
ggml_nbytesFunction · 0.85
ggml_backend_tensor_getFunction · 0.85
sizeMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected