Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-28 08:27:00

0001 // Licensed to the Apache Software Foundation (ASF) under one
0002 // or more contributor license agreements.  See the NOTICE file
0003 // distributed with this work for additional information
0004 // regarding copyright ownership.  The ASF licenses this file
0005 // to you under the Apache License, Version 2.0 (the
0006 // "License"); you may not use this file except in compliance
0007 // with the License.  You may obtain a copy of the License at
0008 //
0009 //   http://www.apache.org/licenses/LICENSE-2.0
0010 //
0011 // Unless required by applicable law or agreed to in writing,
0012 // software distributed under the License is distributed on an
0013 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0014 // KIND, either express or implied.  See the License for the
0015 // specific language governing permissions and limitations
0016 // under the License.
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 }  // namespace internal
0067 }  // namespace arrow