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

Function MakeSparseTensorFromTensor

cpp/src/arrow/sparse_tensor.cc:90–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

MakeMethod · 0.85

Calls 4

InvalidFunction · 0.70

Tested by

no test coverage detected