AlenkaF commented on code in PR #38472: URL: https://github.com/apache/arrow/pull/38472#discussion_r1410498838
########## cpp/src/arrow/dlpack.h: ########## @@ -0,0 +1,32 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "arrow/array/array_base.h" +#include "arrow/dlpack_structure.h" + +namespace arrow { + +/// \brief DLPack protocol for producing DLManagedTensor +/// +/// Returns pointer to the DLManagedTensor class defined by +// the DLPack protocol +ARROW_EXPORT +DLManagedTensor* ExportToDLPack(const std::shared_ptr<Array>& arr); Review Comment: Let me summarize what conclusion we arrived at when talking today: `ExportArray` allocates the `DLManagedTensor` struct that is stored in `DLMTensorCtx`. When PyCapsule calls the deleter (or any C++ consumer) at the end, the deleter removes the context which in turn also cleans up the `DLManagedTensor`, see https://dmlc.github.io/dlpack/latest/c_api.html#_CPPv4N15DLManagedTensor7deleterE: > Destructor - this should be called to destruct the manager_ctx which backs the [DLManagedTensor](https://dmlc.github.io/dlpack/latest/c_api.html#structDLManagedTensor). [...]. The destructors deletes the argument self as well. @pitrou you think we got this right? 😊 ########## cpp/src/arrow/dlpack.h: ########## @@ -0,0 +1,32 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "arrow/array/array_base.h" +#include "arrow/dlpack_structure.h" + +namespace arrow { + +/// \brief DLPack protocol for producing DLManagedTensor +/// +/// Returns pointer to the DLManagedTensor class defined by +// the DLPack protocol +ARROW_EXPORT +DLManagedTensor* ExportToDLPack(const std::shared_ptr<Array>& arr); Review Comment: Let me summarize what conclusion we arrived at when talking today: `ExportArray` allocates the `DLManagedTensor` struct that is stored in `DLMTensorCtx`. When PyCapsule calls the deleter (or any C++ consumer) at the end, the deleter removes the context which in turn also cleans up the `DLManagedTensor`, see https://dmlc.github.io/dlpack/latest/c_api.html#_CPPv4N15DLManagedTensor7deleterE: > Destructor - this should be called to destruct the manager_ctx which backs the [DLManagedTensor](https://dmlc.github.io/dlpack/latest/c_api.html#structDLManagedTensor). [...]. The destructors deletes the argument self as well. @pitrou you think we got this right? 😊 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
