| 26 | namespace { |
| 27 | |
| 28 | Status 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 | |
| 41 | Status DecodeString(const TensorProto& proto, Tensor* tensor) { |
| 42 | auto pstr = tensor->Raw<std::string*>(); |
no test coverage detected