MCPcopy Create free account
hub / github.com/apache/arrow / GetSparseTensorBodyBufferCount

Function GetSparseTensorBodyBufferCount

cpp/src/arrow/ipc/reader.cc:2542–2563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2540namespace {
2541
2542Result<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
2565Status CheckSparseTensorBodyBufferCount(const IpcPayload& payload,
2566 SparseTensorFormat::type sparse_tensor_format_id,

Calls 1

InvalidFunction · 0.50

Tested by

no test coverage detected