| 177 | |
| 178 | template <> |
| 179 | Status TensorSliceWriter::SaveData(const tstring* data, int64 num_elements, |
| 180 | SavedSlice* ss) { |
| 181 | size_t size_bound = ss->ByteSize() + kTensorProtoHeaderBytes + |
| 182 | (num_elements * MaxBytesPerElement(DT_INT32)); |
| 183 | for (int64 i = 0; i < num_elements; ++i) { |
| 184 | size_bound += data[i].size(); |
| 185 | } |
| 186 | if (size_bound > kMaxMessageBytes) { |
| 187 | return errors::InvalidArgument( |
| 188 | "Tensor slice is too large to serialize (conservative estimate: ", |
| 189 | size_bound, " bytes)"); |
| 190 | } |
| 191 | Fill(data, num_elements, ss->mutable_data()); |
| 192 | DCHECK_GE(ss->ByteSize(), 0); |
| 193 | DCHECK_LE(ss->ByteSize(), size_bound); |
| 194 | return Status::OK(); |
| 195 | } |
| 196 | |
| 197 | } // namespace checkpoint |
| 198 |
nothing calls this directly
no test coverage detected