libcudf  23.12.00
interop.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-2023, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 // We disable warning 611 because the `arrow::TableBatchReader` only partially
20 // override the `ReadNext` method of `arrow::RecordBatchReader::ReadNext`
21 // triggering warning 611-D from nvcc.
22 #ifdef __CUDACC__
23 #pragma nv_diag_suppress 611
24 #pragma nv_diag_suppress 2810
25 #endif
26 #include <arrow/api.h>
27 #ifdef __CUDACC__
28 #pragma nv_diag_default 611
29 #pragma nv_diag_default 2810
30 #endif
31 
32 #include <cudf/column/column.hpp>
33 #include <cudf/detail/transform.hpp>
34 #include <cudf/table/table.hpp>
36 #include <cudf/types.hpp>
37 
39 
40 struct DLManagedTensor;
41 
42 namespace cudf {
66 std::unique_ptr<table> from_dlpack(
67  DLManagedTensor const* managed_tensor,
69 
88 DLManagedTensor* to_dlpack(
89  table_view const& input,
91  // end of group
93 
107  std::string name;
108  std::vector<column_metadata> children_meta;
109 
115  column_metadata(std::string const& _name) : name(_name) {}
116  column_metadata() = default;
117 };
118 
139 std::shared_ptr<arrow::Table> to_arrow(table_view input,
140  std::vector<column_metadata> const& metadata = {},
142  arrow::MemoryPool* ar_mr = arrow::default_memory_pool());
143 
161 std::shared_ptr<arrow::Scalar> to_arrow(cudf::scalar const& input,
162  column_metadata const& metadata = {},
164  arrow::MemoryPool* ar_mr = arrow::default_memory_pool());
174 std::unique_ptr<table> from_arrow(
175  arrow::Table const& input,
178 
188 std::unique_ptr<cudf::scalar> from_arrow(
189  arrow::Scalar const& input,
192  // end of group
194 } // namespace cudf
An owning class to represent a singular value.
Definition: scalar.hpp:48
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:187
Class definition for cudf::column.
std::unique_ptr< table > from_arrow(arrow::Table const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Create cudf::table from given arrow Table input.
std::shared_ptr< arrow::Table > to_arrow(table_view input, std::vector< column_metadata > const &metadata={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), arrow::MemoryPool *ar_mr=arrow::default_memory_pool())
Create arrow::Table from cudf table input
std::unique_ptr< table > from_dlpack(DLManagedTensor const *managed_tensor, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Convert a DLPack DLTensor into a cudf table.
DLManagedTensor * to_dlpack(table_view const &input, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Convert a cudf table into a DLPack DLTensor.
device_memory_resource * get_current_device_resource()
cuDF interfaces
Definition: aggregation.hpp:34
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
Detailed metadata information for arrow array.
Definition: interop.hpp:106
std::vector< column_metadata > children_meta
Metadata of children of the column.
Definition: interop.hpp:108
std::string name
Name of the column.
Definition: interop.hpp:107
column_metadata(std::string const &_name)
Construct a new column metadata object.
Definition: interop.hpp:115
Class definition for cudf::table.
Class definitions for (mutable)_table_view
Type declarations for libcudf.