File indexing completed on 2025-08-28 08:27:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #pragma once
0019
0020 #include "arrow/sparse_tensor.h" // IWYU pragma: export
0021
0022 #include <memory>
0023
0024 namespace arrow {
0025 namespace internal {
0026
0027 struct SparseTensorConverterMixin {
0028 static bool IsNonZero(const uint8_t val) { return val != 0; }
0029
0030 static void AssignIndex(uint8_t* indices, int64_t val, const int elsize);
0031
0032 static int64_t GetIndexValue(const uint8_t* value_ptr, const int elsize);
0033 };
0034
0035 Status MakeSparseCOOTensorFromTensor(const Tensor& tensor,
0036 const std::shared_ptr<DataType>& index_value_type,
0037 MemoryPool* pool,
0038 std::shared_ptr<SparseIndex>* out_sparse_index,
0039 std::shared_ptr<Buffer>* out_data);
0040
0041 Status MakeSparseCSXMatrixFromTensor(SparseMatrixCompressedAxis axis,
0042 const Tensor& tensor,
0043 const std::shared_ptr<DataType>& index_value_type,
0044 MemoryPool* pool,
0045 std::shared_ptr<SparseIndex>* out_sparse_index,
0046 std::shared_ptr<Buffer>* out_data);
0047
0048 Status MakeSparseCSFTensorFromTensor(const Tensor& tensor,
0049 const std::shared_ptr<DataType>& index_value_type,
0050 MemoryPool* pool,
0051 std::shared_ptr<SparseIndex>* out_sparse_index,
0052 std::shared_ptr<Buffer>* out_data);
0053
0054 Result<std::shared_ptr<Tensor>> MakeTensorFromSparseCOOTensor(
0055 MemoryPool* pool, const SparseCOOTensor* sparse_tensor);
0056
0057 Result<std::shared_ptr<Tensor>> MakeTensorFromSparseCSRMatrix(
0058 MemoryPool* pool, const SparseCSRMatrix* sparse_tensor);
0059
0060 Result<std::shared_ptr<Tensor>> MakeTensorFromSparseCSCMatrix(
0061 MemoryPool* pool, const SparseCSCMatrix* sparse_tensor);
0062
0063 Result<std::shared_ptr<Tensor>> MakeTensorFromSparseCSFTensor(
0064 MemoryPool* pool, const SparseCSFTensor* sparse_tensor);
0065
0066 }
0067 }