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

Function MakeSparseTensorFromTensor

cpp/src/arrow/sparse_tensor.cc:89–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87#undef CALL_CHECK_MAXIMUM_VALUE
88
89Status MakeSparseTensorFromTensor(const Tensor& tensor,
90 SparseTensorFormat::type sparse_format_id,
91 const std::shared_ptr<DataType>& index_value_type,
92 MemoryPool* pool,
93 std::shared_ptr<SparseIndex>* out_sparse_index,
94 std::shared_ptr<Buffer>* out_data) {
95 switch (sparse_format_id) {
96 case SparseTensorFormat::COO:
97 return MakeSparseCOOTensorFromTensor(tensor, index_value_type, pool,
98 out_sparse_index, out_data);
99 case SparseTensorFormat::CSR:
100 return MakeSparseCSXMatrixFromTensor(SparseMatrixCompressedAxis::ROW, tensor,
101 index_value_type, pool, out_sparse_index,
102 out_data);
103 case SparseTensorFormat::CSC:
104 return MakeSparseCSXMatrixFromTensor(SparseMatrixCompressedAxis::COLUMN, tensor,
105 index_value_type, pool, out_sparse_index,
106 out_data);
107 case SparseTensorFormat::CSF:
108 return MakeSparseCSFTensorFromTensor(tensor, index_value_type, pool,
109 out_sparse_index, out_data);
110
111 // LCOV_EXCL_START: ignore program failure
112 default:
113 return Status::Invalid("Invalid sparse tensor format");
114 // LCOV_EXCL_STOP
115 }
116}
117
118} // namespace internal
119

Callers 1

MakeMethod · 0.85

Calls 4

InvalidFunction · 0.70

Tested by

no test coverage detected