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

Function MakeBuffer

tensorflow/core/distributed_runtime/rpc/grpc_util_test.cc:35–48  ·  view source on GitHub ↗

Return a ByteBuffer that contains str split up into num_slices slices.

Source from the content-addressed store, hash-verified

33
34// Return a ByteBuffer that contains str split up into num_slices slices.
35grpc::ByteBuffer MakeBuffer(const string& str, int num_slices) {
36 // Convert to a ByteBuffer.
37 std::vector<::grpc::Slice> slices;
38 const size_t per_slice = (str.size() + num_slices - 1) / num_slices;
39 for (size_t pos = 0; pos < str.size();) {
40 const size_t n = std::min(str.size() - pos, per_slice);
41 slices.emplace_back(&str[pos], n);
42 pos += n;
43 }
44 if (slices.empty()) {
45 slices.emplace_back();
46 }
47 return ::grpc::ByteBuffer(&slices[0], slices.size());
48}
49
50// Make a proto with approximately the specified length.
51CleanupAllRequest MakeProto(int size) {

Callers 2

TESTFunction · 0.85
BM_ParseGrpcFunction · 0.85

Calls 5

ByteBufferClass · 0.85
minFunction · 0.50
sizeMethod · 0.45
emplace_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected