| 166 | // tensor buffer. |
| 167 | template <typename Source> |
| 168 | static TensorBuffer* Decode(Allocator* a, const Source& in, int64 n) { |
| 169 | if (in.size() != sizeof(T) * n) { |
| 170 | LogUnexpectedSize(in.size(), sizeof(T) * n); |
| 171 | return nullptr; |
| 172 | } |
| 173 | Buffer<T>* buf = new Buffer<T>(a, n); |
| 174 | char* data = buf->template base<char>(); |
| 175 | if (data == nullptr) { |
| 176 | buf->Unref(); |
| 177 | return nullptr; |
| 178 | } |
| 179 | port::CopyToArray(in, data); |
| 180 | return buf; |
| 181 | } |
| 182 | |
| 183 | // Memory usage. |
| 184 | static int64 TotalBytes(TensorBuffer* in, int64 n) { |
nothing calls this directly
no test coverage detected