| 2540 | namespace { |
| 2541 | |
| 2542 | Result<size_t> GetSparseTensorBodyBufferCount(SparseTensorFormat::type format_id, |
| 2543 | const size_t ndim) { |
| 2544 | switch (format_id) { |
| 2545 | case SparseTensorFormat::COO: |
| 2546 | return 2; |
| 2547 | |
| 2548 | case SparseTensorFormat::CSR: |
| 2549 | return 3; |
| 2550 | |
| 2551 | case SparseTensorFormat::CSC: |
| 2552 | return 3; |
| 2553 | |
| 2554 | case SparseTensorFormat::CSF: |
| 2555 | if (ndim < 2) { |
| 2556 | return Status::Invalid("Invalid shape length for a sparse CSF tensor"); |
| 2557 | } |
| 2558 | return 2 * ndim; |
| 2559 | |
| 2560 | default: |
| 2561 | return Status::Invalid("Unrecognized sparse tensor format"); |
| 2562 | } |
| 2563 | } |
| 2564 | |
| 2565 | Status CheckSparseTensorBodyBufferCount(const IpcPayload& payload, |
| 2566 | SparseTensorFormat::type sparse_tensor_format_id, |
no test coverage detected