MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / AddJoinedString

Method AddJoinedString

tensorflow/lite/string_util.cc:43–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43void DynamicBuffer::AddJoinedString(const std::vector<StringRef>& strings,
44 char separator) {
45 // Resize the data buffer.
46 int total_len = strings.size() - 1;
47 for (StringRef ref : strings) {
48 total_len += ref.len;
49 }
50 data_.resize(data_.size() + total_len);
51
52 int current_idx = 0;
53 for (StringRef ref : strings) {
54 char* dst = data_.data() + offset_.back() + current_idx;
55
56 // Fill separator if not first string.
57 if (current_idx != 0) {
58 *dst = separator;
59 ++dst;
60 ++current_idx;
61 }
62
63 // Fill content of the string.
64 memcpy(dst, ref.str, ref.len);
65 current_idx += ref.len;
66 }
67 offset_.push_back(offset_.back() + total_len);
68}
69
70int DynamicBuffer::WriteToBuffer(char** buffer) {
71 // Allocate sufficient memory to tensor buffer.

Callers 2

TESTFunction · 0.80
EvalFunction · 0.80

Calls 5

sizeMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
backMethod · 0.45
push_backMethod · 0.45

Tested by 1

TESTFunction · 0.64