| 2502 | } |
| 2503 | |
| 2504 | Status ReadSparseTensorMetadata(const Buffer& metadata, |
| 2505 | std::shared_ptr<DataType>* out_type, |
| 2506 | std::vector<int64_t>* out_shape, |
| 2507 | std::vector<std::string>* out_dim_names, |
| 2508 | int64_t* out_non_zero_length, |
| 2509 | SparseTensorFormat::type* out_format_id, |
| 2510 | const flatbuf::SparseTensor** out_fb_sparse_tensor, |
| 2511 | const flatbuf::Buffer** out_buffer) { |
| 2512 | RETURN_NOT_OK(internal::GetSparseTensorMetadata( |
| 2513 | metadata, out_type, out_shape, out_dim_names, out_non_zero_length, out_format_id)); |
| 2514 | |
| 2515 | const flatbuf::Message* message = nullptr; |
| 2516 | RETURN_NOT_OK(internal::VerifyMessage(metadata.data(), metadata.size(), &message)); |
| 2517 | |
| 2518 | auto sparse_tensor = message->header_as_SparseTensor(); |
| 2519 | if (sparse_tensor == nullptr) { |
| 2520 | return Status::IOError( |
| 2521 | "Header-type of flatbuffer-encoded Message is not SparseTensor."); |
| 2522 | } |
| 2523 | *out_fb_sparse_tensor = sparse_tensor; |
| 2524 | |
| 2525 | auto buffer = sparse_tensor->data(); |
| 2526 | if (!bit_util::IsMultipleOf8(buffer->offset())) { |
| 2527 | return Status::Invalid( |
| 2528 | "Buffer of sparse index data did not start on 8-byte aligned offset: ", |
| 2529 | buffer->offset()); |
| 2530 | } |
| 2531 | *out_buffer = buffer; |
| 2532 | |
| 2533 | return Status::OK(); |
| 2534 | } |
| 2535 | |
| 2536 | } // namespace |
| 2537 |
no test coverage detected