aboutsummaryrefslogtreecommitdiff
path: root/src/c/cl/AclOpenClExt.cpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2021-02-23 10:01:33 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2021-04-06 12:48:34 +0000
commit3f26ef4f9a2d447adb324dd69aec7c49cf7905fc (patch)
tree7f0e38f2f1675cfa97644f3309a20e296b6cddfd /src/c/cl/AclOpenClExt.cpp
parent7a452fe8630b3ce0a58f63869178d06aaba325fc (diff)
downloadComputeLibrary-3f26ef4f9a2d447adb324dd69aec7c49cf7905fc.tar.gz
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 <georgios.pinitas@arm.com> Change-Id: I02734ac6ad85700d91d6e73217b4637adbf5d177 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5260 Tested-by: Arm Jenkins <bsgcomp@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/c/cl/AclOpenClExt.cpp')
-rw-r--r--src/c/cl/AclOpenClExt.cpp29
1 files changed, 29 insertions, 0 deletions
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)
@@ -80,4 +83,30 @@ extern "C" AclStatus AclSetClContext(AclContext external_ctx, cl_context opencl_
}
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<arm_compute::ICLTensor *>(tensor->tensor());
+ *opencl_mem = cl_tensor->cl_buffer().get();
+
+ return AclStatus::AclSuccess;
} \ No newline at end of file