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

Function GetSparseTensorBodyBufferCount

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

Source from the content-addressed store, hash-verified

2523namespace {
2524
2525Result<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
2548Status CheckSparseTensorBodyBufferCount(const IpcPayload& payload,
2549 SparseTensorFormat::type sparse_tensor_format_id,

Calls 1

InvalidFunction · 0.50

Tested by

no test coverage detected