From 3f26ef4f9a2d447adb324dd69aec7c49cf7905fc Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 23 Feb 2021 10:01:33 +0000 Subject: Add tensor related data structures for the new API Adds the following: - TensorDescriptor: which is responsible for holding the information needed to represent a tensor (e.g. shape, dimensions, etc) - Tensor: an aggreate object of a descriptor and a backing memory - TensorPack: A map of tensor that can be passed to operators as inputs/outputs Signed-off-by: Georgios Pinitas Change-Id: I02734ac6ad85700d91d6e73217b4637adbf5d177 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5260 Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins --- src/c/cl/AclOpenClExt.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/c/cl/AclOpenClExt.cpp') diff --git a/src/c/cl/AclOpenClExt.cpp b/src/c/cl/AclOpenClExt.cpp index 5f2bb47c16..a144f97f55 100644 --- a/src/c/cl/AclOpenClExt.cpp +++ b/src/c/cl/AclOpenClExt.cpp @@ -23,9 +23,12 @@ */ #include "arm_compute/AclOpenClExt.h" +#include "src/common/ITensor.h" #include "src/common/Types.h" #include "src/gpu/cl/ClContext.h" +#include "arm_compute/core/CL/ICLTensor.h" + #include "support/Cast.h" extern "C" AclStatus AclGetClContext(AclContext external_ctx, cl_context *opencl_context) @@ -79,5 +82,31 @@ extern "C" AclStatus AclSetClContext(AclContext external_ctx, cl_context opencl_ return AclStatus::AclRuntimeError; } + return AclStatus::AclSuccess; +} + +extern "C" AclStatus AclGetClMem(AclTensor external_tensor, cl_mem *opencl_mem) +{ + using namespace arm_compute; + ITensorV2 *tensor = get_internal(external_tensor); + + if(detail::validate_internal_tensor(tensor) != StatusCode::Success) + { + return AclStatus::AclInvalidArgument; + } + + if(tensor->header.ctx->type() != Target::GpuOcl) + { + return AclStatus::AclInvalidTarget; + } + + if(opencl_mem == nullptr) + { + return AclStatus::AclInvalidArgument; + } + + auto cl_tensor = utils::cast::polymorphic_downcast(tensor->tensor()); + *opencl_mem = cl_tensor->cl_buffer().get(); + return AclStatus::AclSuccess; } \ No newline at end of file -- cgit v1.2.1