| 2310 | namespace { |
| 2311 | |
| 2312 | Status ValidateSparseCSFIndexMetadata(const flatbuf::SparseTensorIndexCSF* sparse_index, |
| 2313 | int64_t ndim) { |
| 2314 | if (sparse_index == nullptr) { |
| 2315 | return Status::Invalid("Missing CSF sparse index metadata"); |
| 2316 | } |
| 2317 | auto* indptr_buffers = sparse_index->indptrBuffers(); |
| 2318 | auto* indices_buffers = sparse_index->indicesBuffers(); |
| 2319 | auto* axis_order = sparse_index->axisOrder(); |
| 2320 | if (ndim < 2 || indptr_buffers == nullptr || indices_buffers == nullptr || |
| 2321 | axis_order == nullptr || static_cast<int64_t>(indptr_buffers->size()) != ndim - 1 || |
| 2322 | static_cast<int64_t>(indices_buffers->size()) != ndim || |
| 2323 | static_cast<int64_t>(axis_order->size()) != ndim) { |
| 2324 | return Status::Invalid( |
| 2325 | "Inconsistent CSF sparse index: a CSF tensor must have at least 2 dimensions " |
| 2326 | "with indptr, indices and axis_order counts of ndim - 1, ndim and ndim"); |
| 2327 | } |
| 2328 | return Status::OK(); |
| 2329 | } |
| 2330 | |
| 2331 | Result<std::shared_ptr<SparseIndex>> ReadSparseCOOIndex( |
| 2332 | const flatbuf::SparseTensor* sparse_tensor, const std::vector<int64_t>& shape, |
no test coverage detected