MCPcopy Create free account
hub / github.com/alibaba/euler / EncodeString

Function EncodeString

euler/core/framework/tensor_util.cc:28–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26namespace {
27
28Status EncodeString(const Tensor& tensor, TensorProto* proto) {
29 std::string buffer;
30 auto ptr = tensor.Raw<std::string*>();
31 for (int i = 0; i < tensor.NumElements(); ++i) {
32 uint32_t len = (*ptr)->size();
33 buffer.append(reinterpret_cast<char*>(&len), sizeof(len));
34 buffer.append(**ptr);
35 ++ptr;
36 }
37 proto->set_tensor_content(buffer);
38 return Status::OK();
39}
40
41Status DecodeString(const TensorProto& proto, Tensor* tensor) {
42 auto pstr = tensor->Raw<std::string*>();

Callers 1

EncodeFunction · 0.85

Calls 3

appendMethod · 0.80
NumElementsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected