| 2293 | namespace { |
| 2294 | |
| 2295 | Status ValidateSparseCSFIndexMetadata(const flatbuf::SparseTensorIndexCSF* sparse_index, |
| 2296 | int64_t ndim) { |
| 2297 | if (sparse_index == nullptr) { |
| 2298 | return Status::Invalid("Missing CSF sparse index metadata"); |
| 2299 | } |
| 2300 | auto* indptr_buffers = sparse_index->indptrBuffers(); |
| 2301 | auto* indices_buffers = sparse_index->indicesBuffers(); |
| 2302 | auto* axis_order = sparse_index->axisOrder(); |
| 2303 | if (ndim < 2 || indptr_buffers == nullptr || indices_buffers == nullptr || |
| 2304 | axis_order == nullptr || static_cast<int64_t>(indptr_buffers->size()) != ndim - 1 || |
| 2305 | static_cast<int64_t>(indices_buffers->size()) != ndim || |
| 2306 | static_cast<int64_t>(axis_order->size()) != ndim) { |
| 2307 | return Status::Invalid( |
| 2308 | "Inconsistent CSF sparse index: a CSF tensor must have at least 2 dimensions " |
| 2309 | "with indptr, indices and axis_order counts of ndim - 1, ndim and ndim"); |
| 2310 | } |
| 2311 | return Status::OK(); |
| 2312 | } |
| 2313 | |
| 2314 | Result<std::shared_ptr<SparseIndex>> ReadSparseCOOIndex( |
| 2315 | const flatbuf::SparseTensor* sparse_tensor, const std::vector<int64_t>& shape, |
no test coverage detected