| 1515 | } |
| 1516 | |
| 1517 | Status GetSparseCSFIndexMetadata(const flatbuf::SparseTensorIndexCSF* sparse_index, |
| 1518 | std::vector<int64_t>* axis_order, |
| 1519 | std::vector<int64_t>* indices_size, |
| 1520 | std::shared_ptr<DataType>* indptr_type, |
| 1521 | std::shared_ptr<DataType>* indices_type) { |
| 1522 | RETURN_NOT_OK(IntFromFlatbuffer(sparse_index->indptrType(), indptr_type)); |
| 1523 | RETURN_NOT_OK(IntFromFlatbuffer(sparse_index->indicesType(), indices_type)); |
| 1524 | |
| 1525 | auto* fb_axis_order = sparse_index->axisOrder(); |
| 1526 | auto* fb_indices_buffers = sparse_index->indicesBuffers(); |
| 1527 | // ValidateSparseCSFIndexMetadata already checks this, keep this check defensively. |
| 1528 | if (fb_axis_order == nullptr || fb_indices_buffers == nullptr || |
| 1529 | fb_axis_order->size() != fb_indices_buffers->size()) { |
| 1530 | return Status::Invalid( |
| 1531 | "Inconsistent CSF sparse index: axisOrder and indicesBuffers have different " |
| 1532 | "lengths"); |
| 1533 | } |
| 1534 | |
| 1535 | const int ndim = static_cast<int>(fb_axis_order->size()); |
| 1536 | for (int i = 0; i < ndim; ++i) { |
| 1537 | axis_order->push_back(fb_axis_order->Get(i)); |
| 1538 | indices_size->push_back(fb_indices_buffers->Get(i)->length()); |
| 1539 | } |
| 1540 | |
| 1541 | return Status::OK(); |
| 1542 | } |
| 1543 | |
| 1544 | Status GetSparseTensorMetadata(const Buffer& metadata, std::shared_ptr<DataType>* type, |
| 1545 | std::vector<int64_t>* shape, |