From ff9b62986ec28c3b17f4a5478d10f6acc521cf89 Mon Sep 17 00:00:00 2001 From: chengfeng27 Date: Sun, 28 Apr 2024 16:57:27 +0800 Subject: [PATCH] add tensor allocator api Signed-off-by: chengfeng27 --- third_party/mindspore/kits/tensor.h | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/third_party/mindspore/kits/tensor.h b/third_party/mindspore/kits/tensor.h index b0ff5fea1..e193ad1ec 100644 --- a/third_party/mindspore/kits/tensor.h +++ b/third_party/mindspore/kits/tensor.h @@ -47,6 +47,13 @@ extern "C" { typedef void *OH_AI_TensorHandle; +/** + * @brief tensor allocator handle. + * + * @since 12 + */ +typedef void *OH_AI_AllocatorHandle; + /** * @brief Create a tensor object. * @param name The name of the tensor. @@ -198,6 +205,30 @@ 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