| 1202 | } |
| 1203 | |
| 1204 | Status MakeSparseTensorIndex(FBB& fbb, const SparseIndex& sparse_index, |
| 1205 | const std::vector<BufferMetadata>& buffers, |
| 1206 | flatbuf::SparseTensorIndex* fb_sparse_index_type, |
| 1207 | Offset* fb_sparse_index, size_t* num_buffers) { |
| 1208 | switch (sparse_index.format_id()) { |
| 1209 | case SparseTensorFormat::COO: |
| 1210 | RETURN_NOT_OK(MakeSparseTensorIndexCOO( |
| 1211 | fbb, checked_cast<const SparseCOOIndex&>(sparse_index), buffers, |
| 1212 | fb_sparse_index_type, fb_sparse_index, num_buffers)); |
| 1213 | break; |
| 1214 | |
| 1215 | case SparseTensorFormat::CSR: |
| 1216 | RETURN_NOT_OK(MakeSparseMatrixIndexCSX( |
| 1217 | fbb, checked_cast<const SparseCSRIndex&>(sparse_index), buffers, |
| 1218 | fb_sparse_index_type, fb_sparse_index, num_buffers)); |
| 1219 | break; |
| 1220 | |
| 1221 | case SparseTensorFormat::CSC: |
| 1222 | RETURN_NOT_OK(MakeSparseMatrixIndexCSX( |
| 1223 | fbb, checked_cast<const SparseCSCIndex&>(sparse_index), buffers, |
| 1224 | fb_sparse_index_type, fb_sparse_index, num_buffers)); |
| 1225 | break; |
| 1226 | |
| 1227 | case SparseTensorFormat::CSF: |
| 1228 | RETURN_NOT_OK(MakeSparseTensorIndexCSF( |
| 1229 | fbb, checked_cast<const SparseCSFIndex&>(sparse_index), buffers, |
| 1230 | fb_sparse_index_type, fb_sparse_index, num_buffers)); |
| 1231 | break; |
| 1232 | |
| 1233 | default: |
| 1234 | *fb_sparse_index_type = |
| 1235 | flatbuf::SparseTensorIndex::SparseTensorIndex_NONE; // Silence warnings |
| 1236 | std::stringstream ss; |
| 1237 | ss << "Unsupported sparse tensor format:: " << sparse_index.ToString() << std::endl; |
| 1238 | return Status::NotImplemented(ss.str()); |
| 1239 | } |
| 1240 | |
| 1241 | return Status::OK(); |
| 1242 | } |
| 1243 | |
| 1244 | Status MakeSparseTensor(FBB& fbb, const SparseTensor& sparse_tensor, int64_t body_length, |
| 1245 | const std::vector<BufferMetadata>& buffers, |
no test coverage detected