From 4164814a099773c0a512889473c980bc148e590f Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 3 Aug 2021 08:24:00 +0100 Subject: Implement Operator API Resolves: COMPMID-4512 Signed-off-by: Georgios Pinitas Change-Id: Id12130365fa3fe2261160931dcc7affb6b467186 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6031 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- src/runtime/gpu/cl/operators/ClActivation.cpp | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/runtime/gpu/cl/operators') diff --git a/src/runtime/gpu/cl/operators/ClActivation.cpp b/src/runtime/gpu/cl/operators/ClActivation.cpp index 71aa57bdbd..bef42d7fae 100644 --- a/src/runtime/gpu/cl/operators/ClActivation.cpp +++ b/src/runtime/gpu/cl/operators/ClActivation.cpp @@ -26,6 +26,10 @@ #include "src/core/gpu/cl/ClCompileContext.h" #include "src/core/gpu/cl/kernels/ClActivationKernel.h" +#include "src/common/IOperator.h" +#include "src/common/utils/LegacySupport.h" +#include "src/gpu/cl/ClContext.h" + namespace arm_compute { namespace opencl @@ -42,4 +46,35 @@ Status ClActivation::validate(const ITensorInfo *src, const ITensorInfo *dst, co return kernels::ClActivationKernel::validate(src, dst, act_info); } } // namespace opencl + +namespace gpu +{ +namespace opencl +{ +std::tuple ClContext::create_activation(const AclTensorDescriptor &src, const AclTensorDescriptor &dst, const AclActivationDescriptor &act, bool is_validate) +{ + TensorInfo src_info = detail::convert_to_legacy_tensor_info(src); + TensorInfo dst_info = detail::convert_to_legacy_tensor_info(dst); + auto info = detail::convert_to_activation_info(act); + + if(is_validate && !bool(arm_compute::opencl::ClActivation::validate(&src_info.set_is_resizable(false), &dst_info.set_is_resizable(false), info))) + { + return std::make_tuple(nullptr, StatusCode::UnsupportedConfig); + } + + auto act_op = std::make_unique(); + act_op->configure(CLKernelLibrary::get().get_compile_context(), &src_info, &dst_info, info); + + auto op = new arm_compute::IOperator(static_cast(this)); + if(op == nullptr) + { + ARM_COMPUTE_LOG_ERROR_ACL("Couldn't allocate internal resources"); + return { nullptr, StatusCode::OutOfMemory }; + } + op->set_internal_operator(std::move(act_op)); + + return std::make_tuple(op, StatusCode::Success); +} +} // namespace opencl +} // namespace gpu } // namespace arm_compute -- cgit v1.2.1