| 162 | |
| 163 | template <typename T> |
| 164 | Status TensorSliceWriter::SaveData(const T* data, int64 num_elements, |
| 165 | SavedSlice* ss) { |
| 166 | size_t size_bound = |
| 167 | ss->ByteSize() + kTensorProtoHeaderBytes + |
| 168 | (MaxBytesPerElement(DataTypeToEnum<T>::value) * num_elements); |
| 169 | if (size_bound > kMaxMessageBytes) { |
| 170 | return errors::InvalidArgument( |
| 171 | "Tensor slice is too large to serialize (conservative estimate: ", |
| 172 | size_bound, " bytes)"); |
| 173 | } |
| 174 | Fill(data, num_elements, ss->mutable_data()); |
| 175 | DCHECK_GE(ss->ByteSize(), 0); |
| 176 | DCHECK_LE(ss->ByteSize(), size_bound); |
| 177 | return Status::OK(); |
| 178 | } |
| 179 | |
| 180 | template <> |
| 181 | Status TensorSliceWriter::SaveData(const tstring* data, int64 num_elements, |
nothing calls this directly
no test coverage detected