From 033f7232422e7d1875f49161f1270ec7d1641d5d Mon Sep 17 00:00:00 2001 From: qinzheng4 Date: Wed, 31 Jan 2024 15:59:49 +0800 Subject: [PATCH] add tensor allocator api Signed-off-by: qinzheng4 --- third_party/mindspore/kits/tensor.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/third_party/mindspore/kits/tensor.h b/third_party/mindspore/kits/tensor.h index b0ff5fea1..b2ef4e6d6 100644 --- a/third_party/mindspore/kits/tensor.h +++ b/third_party/mindspore/kits/tensor.h @@ -46,6 +46,7 @@ extern "C" { #endif typedef void *OH_AI_TensorHandle; +typedef void *OH_AI_AllocatorHandle; /** * @brief Create a tensor object. @@ -198,6 +199,32 @@ OH_AI_API size_t OH_AI_TensorGetDataSize(const OH_AI_TensorHandle tensor); */ OH_AI_API OH_AI_Status OH_AI_TensorSetUserData(OH_AI_TensorHandle tensor, void *data, size_t data_size); +/** + * @brief Get allocator for the tensor. + * + * The main purpose of this interface is providing a way of getting memory allocator of the tensor. + * + * @param tensor Tensor object handle. + * @return handle of the tensor's allocator. + * @since 12 + */ + +OH_AI_API OH_AI_AllocatorHandle OH_AI_TensorGetAllocator(OH_AI_TensorHandle tensor); + +/** + * @brief Set allocator to the tensor. + * + * The main purpose of this interface is providing a way of setting memory allocator, so tensor's memory will be allocated + * by this allocator. + * + * @param tensor Tensor object handle. + * @param allocator A allocator handle. + * @return OH_AI_STATUS_SUCCESS if success, or detail error code if failed. + * @since 12 + */ + +OH_AI_API OH_AI_Status OH_AI_TensorSetAllocator(OH_AI_TensorHandle tensor, OH_AI_AllocatorHandle allocator); + #ifdef __cplusplus } #endif -- Gitee