| 2523 | namespace { |
| 2524 | |
| 2525 | Result<size_t> GetSparseTensorBodyBufferCount(SparseTensorFormat::type format_id, |
| 2526 | const size_t ndim) { |
| 2527 | switch (format_id) { |
| 2528 | case SparseTensorFormat::COO: |
| 2529 | return 2; |
| 2530 | |
| 2531 | case SparseTensorFormat::CSR: |
| 2532 | return 3; |
| 2533 | |
| 2534 | case SparseTensorFormat::CSC: |
| 2535 | return 3; |
| 2536 | |
| 2537 | case SparseTensorFormat::CSF: |
| 2538 | if (ndim < 2) { |
| 2539 | return Status::Invalid("Invalid shape length for a sparse CSF tensor"); |
| 2540 | } |
| 2541 | return 2 * ndim; |
| 2542 | |
| 2543 | default: |
| 2544 | return Status::Invalid("Unrecognized sparse tensor format"); |
| 2545 | } |
| 2546 | } |
| 2547 | |
| 2548 | Status CheckSparseTensorBodyBufferCount(const IpcPayload& payload, |
| 2549 | SparseTensorFormat::type sparse_tensor_format_id, |
no test coverage detected