Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-28 08:26:55

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/array/array_base.h"
0021 #include "arrow/c/dlpack_abi.h"
0022 
0023 namespace arrow::dlpack {
0024 
0025 /// \brief Export Arrow array as DLPack tensor.
0026 ///
0027 /// DLMangedTensor is produced as defined by the DLPack protocol,
0028 /// see https://dmlc.github.io/dlpack/latest/.
0029 ///
0030 /// Data types for which the protocol is supported are
0031 /// integer and floating-point data types.
0032 ///
0033 /// DLPack protocol only supports arrays with one contiguous
0034 /// memory region which means Arrow Arrays with validity buffers
0035 /// are not supported.
0036 ///
0037 /// \param[in] arr Arrow array
0038 /// \return DLManagedTensor struct
0039 ARROW_EXPORT
0040 Result<DLManagedTensor*> ExportArray(const std::shared_ptr<Array>& arr);
0041 
0042 /// \brief Get DLDevice with enumerator specifying the
0043 /// type of the device data is stored on and index of the
0044 /// device which is 0 by default for CPU.
0045 ///
0046 /// \param[in] arr Arrow array
0047 /// \return DLDevice struct
0048 ARROW_EXPORT
0049 Result<DLDevice> ExportDevice(const std::shared_ptr<Array>& arr);
0050 
0051 }  // namespace arrow::dlpack